How get AD_PERFORMANCE_REPORT as array or json instead of downloading

342 views
Skip to first unread message

sijo vijayan

unread,
May 6, 2015, 10:49:52 AM5/6/15
to adwor...@googlegroups.com

Hi,
I am a newcomer in AdWords API , I need to take AD_PERFORMANCE_REPORT using Adwords API, Currently i am able to download the report using the following code, But i need to take the data as an array or any other format instead of downloading, I have attached the dashboard view also. Please help me.

function DownloadCriteriaReportExample(AdWordsUser $user, $filePath) {

  $user->LoadService('ReportDefinitionService');

  $selector = new Selector();
 
  $selector->fields = array('Headline','Description1','Description2','DisplayUrl','AdGroupName','CampaignName','Clicks','ConversionsManyPerClick');

  $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('PAUSED'));
 
  $reportDefinition = new ReportDefinition();
  $reportDefinition->selector = $selector;
  $reportDefinition->reportName = 'ad performance report #' . uniqid();
  $reportDefinition->dateRangeType = 'LAST_30_DAYS';
  $reportDefinition->reportType = 'AD_PERFORMANCE_REPORT';
  $reportDefinition->downloadFormat = 'CSV';

  $reportDefinition->includeZeroImpressions = FALSE;

  $options = array('version' => 'v201502');
 
  ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);

  printf("Report with name '%s' was downloaded to '%s'.\n",
      $reportDefinition->reportName, $filePath);
}



Raghavendra Soudala (AdWords API Team)

unread,
May 6, 2015, 5:38:16 PM5/6/15
to adwor...@googlegroups.com, sijovij...@gmail.com
Hi Vijayan

If you do not pass a file path, then DownloadReport will return the contents of the response as a string. Check out the function description on github for more details. I hope it solves your problem.

Cheers,
Raghavendra, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages