Retrieving all data for last year from CAMPAIGN_PERFORMANCE_REPORT

94 views
Skip to first unread message

teste...@gmail.com

unread,
Jul 7, 2016, 2:32:35 AM7/7/16
to AdWords API Forum
Hello,

I am trying to store 1 years worth of data into my database. Now I have a test account and no actual data, so I can't really test this well.

I want to retrieve the last years data even if there is no actual changes in data.

    $reportQuery = 'SELECT Date, CampaignId, CampaignName, Impressions, Clicks, Cost, Conversions, CostPerConversion FROM CAMPAIGN_PERFORMANCE_REPORT DURING 20160101, 20160707';


    $reportUtils
= new ReportUtils();
    $data
= $reportUtils->DownloadReportWithAwql($reportQuery, null, $user, "CSV");

I get the following as a result

CAMPAIGN_PERFORMANCE_REPORT (Jan 1, 2016-Jul 7, 2016)
Day,Campaign ID,Campaign,Impressions,Clicks,Cost,Conversions,Cost / conv.
Total, --, --,0,0,0,0.0,0

As you can see no data, I wanted this to be filled with --, --,0,0,0,0.0,0 for each day.


Any idea on how to achieve this?

Also setting these header values don't seem to work as I am getting it in the response anyway.

 $user
= new AdWordsUser();
 $user
->SetClientCustomerId("token");
 $user
->SetDeveloperToken($devToken);
 $user
->setUserAgent($userAgent);
 $user
->SetHeaderValue("includeZeroImpressions", true);
 $user
->SetHeaderValue("skipColumnHeader", true);
 $user
->SetHeaderValue("skipReportHeader", true);
 $user
->SetHeaderValue("skipReportSummary", true);


Peter Oliquino

unread,
Jul 7, 2016, 3:34:28 AM7/7/16
to AdWords API Forum
Hi,

I tested your AWQL query using my own test account and found that your query should work fine in getting the (test account) results. In addition, you will need to specify a file path in the $reportUtils in order for you to be able to download the file into a CSV (or other format) output file. 

Please also note that report generation is supported only at the account level, meaning, the clientCustomerId specified in your auth.ini file should be that of a client account instead of a manager account. You could check our reporting guide for more information and also check here for a more concrete example of generating a report (including the option on how to suppress the headers) using PHP.

I hope this helps.

Thanks,
Peter
AdWords API Team

teste...@gmail.com

unread,
Jul 7, 2016, 4:43:42 AM7/7/16
to AdWords API Forum

I am not trying to save a file just save it into a database.

I am doing this dynamically, as my service allows users to signup and show their data via a dashboard of our own.

The desired response I wanted from the report would be
CAMPAIGN_PERFORMANCE_REPORT (Jan 1, 2016-Jul 7, 2016)
Day,Campaign ID,Campaign,Impressions,Clicks,Cost,Conversions,Cost / conv.
20160707, <campaign id>,0,0,0,0.0,0
20160706, <campaign id>,2,0,0,0.0,0
20160705, <campaign id>,0,5,0,0.0,0
20160704, <campaign id>,1,0,1,0.0,0
20160703, <campaign id>,0,0,0,1.0,1
20160702, <campaign id>,0,0,0,0.0,0
20160701, <campaign id>,0,0,0,0.0,0
Total, --, --,0,0,0,0.0,0

as you can see in the above example it loads data from days with all 0's.

teste...@gmail.com

unread,
Jul 7, 2016, 5:34:05 AM7/7/16
to AdWords API Forum
Here is an image of my test account setup.
adwords.jpg

Peter Oliquino

unread,
Jul 7, 2016, 6:17:36 AM7/7/16
to AdWords API Forum
Hi,

Thanks for the additional information. To further investigate the issue regarding the no data, could you kindly provide the customer Id of the test account? Also, please do so using Reply privately to author.

Regards,
Peter
AdWords API Team

teste...@gmail.com

unread,
Jul 9, 2016, 12:57:49 AM7/9/16
to AdWords API Forum
The issue was the way I set the headers for 0 result entries.

to fix this, you must do the following to set the header for reports.

To set the values for the request headers for a report request, you need to set the options like this:

$options = array('version' => ADWORDS_VERSION);
$options
['includeZeroImpressions'] = true;           //includes zero impression rows in the report output.
ReportUtils::DownloadReportWithAwql($reportQuery, $filePath, $user, $reportFormat, $options);

Thank you to the api team for helping me out with that.


Reply all
Reply to author
Forward
0 new messages