i using php total count on campaign in google adwords each keyword. have setup issue report downloading does't contain data.
my function report:
function downloadkeywordreport(adwordsuser $user, $filepath, $keyword_id) { // load service, required classes available. $user->loadservice('reportdefinitionservice'); // create selector. $selector = new selector(); $selector->fields = array('clicks', 'id', 'conversionvalue'); // filter out deleted criteria. //$selector->predicates[] = new predicate('status', 'not_in', array('deleted')); $selector->predicates[] = new predicate('id', 'in', array($keyword_id)); // create report definition. $reportdefinition = new reportdefinition(); $reportdefinition->selector = $selector; $reportdefinition->reportname = 'criteria performance report #' . uniqid(); //$reportdefinition->daterangetype = 'custom_date'; $reportdefinition->daterangetype = 'last_7_days'; $reportdefinition->reporttype = 'keywords_performance_report'; $reportdefinition->downloadformat = 'xml'; // exclude criteria haven't recieved impressions on date range. $reportdefinition->includezeroimpressions = false; // set additional options. $options = array('returnmoneyinmicros' => false); reportutils::downloadreport($reportdefinition, $filepath, $user, $options); printf("report name '%s' downloaded '%s'.\n", $reportdefinition->reportname, $filepath); $doc = new domdocument(); $doc->loadxml(file_get_contents($filepath)); $xp = new domxpath($doc); $q = $xp->query("/report/table/row/@cost"); } and xml report generated
<report> <report-name name="criteria performance report #559f659c928ac"/><date-range date="jul 3, 2015-jul 9, 2015"/> <table> <columns> <column name="clicks" display="clicks"/> <column name="keywordid" display="keyword id"/> <column name="totalconvvalue" display="total conv. value"/></columns> </table> </report> if use google adsense preview tool not showing adds here. doing wrong or possibilities test account?
a test account doesn't accumulate impressions (as ads not being shown), you'll need set
$reportdefinition->includezeroimpressions = true;
Comments
Post a Comment