google adwords api php library -
i have setup account mcc account , executed examples reporting code campaign performance report 1 of customerclient id.
this code:
<?php // include initialization file require_once __dir__ . '/examples/adwords/auth/init.php'; require_once __dir__. '/src/google/api/ads/adwords/util/v201601/reportutils.php'; function downloadcriteriareportwithawqlexample(adwordsuser $user, $filepath, $reportformat) { // optional: set clientcustomerid reports of child accounts $user->setclientcustomerid('731-721-7585'); // prepare date range last week. instead can use 'last_7_days'. // $daterange = 'all_time'; // create report query. $reportquery = 'select campaignname, impressions, clicks, ctr, averagecpc, ' . 'cost, date,conversions,conversionrate, costperconversion,campaignstatus campaign_performance_report ' . 'where campaignstatus = enabled during this_month'; // set additional options. $options = array('version' => 'v201601'); // download report. $reportutils = new reportutils(); $reportutils->downloadreportwithawql($reportquery, $filepath, $user, $reportformat, $options); printf("report downloaded '%s'.\n", $filepath); } try { // adwordsuser credentials in "../auth.ini" // relative adwordsuser.php file's directory. $user = new adwordsuser(); // log every soap xml request , response. $user->logall(); // download report file in same directory example. $filepath = dirname(__file__) . '/report.csv'; $reportformat = 'csv'; // run example. downloadcriteriareportwithawqlexample($user, $filepath, $reportformat); } catch (exception $e) { printf("an error has occurred: %s\n", $e->getmessage()); } // don't run example if file being included. if (__file__ != realpath($_server['php_self'])) { return; }
i have executed code , got csv report have 2 fields averagecpc, , cost.
both of these parameters must rounded of or should return in same format see in google adwords campaigns dashboard.
here screenshot of how looks csv file
avg.cpc | cost 9788919 | 362190000
but when validated adwords campaigns, shows.
avg.cpc | cost 9.7 | 36.21
is there problem code or need specify parameters avgcpc value , cost format ???
for this, have divide cost , average cpc 1000000, format before may process data further.
Comments
Post a Comment