AdWords Reporting - PHP

99 views
Skip to first unread message

ejay.o...@momentummedia.com.au

unread,
Aug 23, 2017, 12:48:04 AM8/23/17
to AdWords API Forum
Hi Adbutler Team,

Is there a way I can get generated data only, not downloading via csv?

I need an object or array data produced by this sample query:

$reportQuery = 'SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
        . 'Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT '
        . 'WHERE Status IN [ENABLED, PAUSED] DURING LAST_7_DAYS';

Thanks,

Ejay

Vincent Racaza (AdWords API Team)

unread,
Aug 23, 2017, 2:25:57 AM8/23/17
to AdWords API Forum
Hi Ejay,

Aside from downloading the report file, you can also get the report data as String object:
// $reportDownloadResult->saveToFile($filePath);
print $reportDownloadResult->getAsString();

From the String object, you can then do a post-processing on your end to transform the value of the String object into another object or array based on your use-case.

Thanks,
Vincent
AdWords API Team

ejay.o...@momentummedia.com.au

unread,
Aug 23, 2017, 2:44:00 AM8/23/17
to AdWords API Forum
Hi Vincent,

Thank you for the response.

Another question, Upon executing the sample codes of reporting. It gives me 0 result though i have 2 sample campaigns but have no impressions and clicks because this is under by test client account.
Do I have to create reporting table/charts in "Reports" of adwords web interface?

Thanks,
Ejay

Note: I need impressions and clicks per campaign.

Vincent Racaza (AdWords API Team)

unread,
Aug 23, 2017, 4:40:44 AM8/23/17
to AdWords API Forum
Hi Ejay,

For test accounts, all statistics like impressions and clicks would have 0 as value as the ads doesn't really serve. You can get a report with these two campaigns but with no impressions and clicks. Just ensure that the includeZeroImpressions is set to true so that these campaigns will be returned.

Let me know if you have further clarifications.

ejay.o...@momentummedia.com.au

unread,
Aug 23, 2017, 5:34:18 AM8/23/17
to AdWords API Forum
Hi Vincent,

It worked! Perfect! 

Last question, can i select or query a report via campaign ID? so that it would not generate all reports. I tried adding "CampaignId = (campaignid)" in "WHERE" of $reportQuery but it didn't work.

Cheers,

Ejay

Vincent Racaza (AdWords API Team)

unread,
Aug 23, 2017, 6:52:30 AM8/23/17
to AdWords API Forum
Hi Ejay,

Yes, you can filter by CampaignId in the WHERE clause for the Criteria Performance Report. You can refer to the code snippet below:

'WHERE CampaignId = "INSERT_CAMPAIGN_ID_HERE" ';
//Or you can also filter this way:
//'WHERE CampaignId = \'INSERT_CAMPAIGN_ID_HERE\' ';

Let me know if this helps. If you encounter any error, kindly provide your PHP code via Reply privately to author so I could further check.

ejay.o...@momentummedia.com.au

unread,
Aug 23, 2017, 8:12:58 PM8/23/17
to AdWords API Forum
Hi Vincent,

It worked! Cool!

Cheers,

Ejay
Reply all
Reply to author
Forward
0 new messages