almo
almo

Reputation: 6387

AdWords API PHP - Click Performance Report

I am trying to download a click performance report from the AdWords-API. For my example I am only selecting the Date field.

function DownloadCriteriaReportExample(AdWordsUser $user, $filePath) {
  // Load the service, so that the required classes are available.
  $user->LoadService('ReportDefinitionService', ADWORDS_VERSION);

  // Create selector.
  $selector = new Selector();
  $selector->fields = array('Date');

  // Filter out deleted criteria.
  $selector->predicates[] = new Predicate('Status', 'NOT_IN', array('DELETED'));

  // Create report definition.
  $reportDefinition = new ReportDefinition();
  $reportDefinition->selector = $selector;
  $reportDefinition->reportName = 'Criteria performance report #' . uniqid();
  $reportDefinition->dateRangeType = 'YESTERDAY';
  $reportDefinition->reportType = 'CLICK_PERFORMANCE_REPORT';
  $reportDefinition->downloadFormat = 'CSV';

  // Exclude criteria that haven't recieved any impressions over the date range.
  $reportDefinition->includeZeroImpressions = FALSE;

  // Set additional options.
  $options = array('version' => ADWORDS_VERSION, 'returnMoneyInMicros' => TRUE);

  // Download report.
  ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);

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

The error I get ist: "ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT". The same script runs with no problems for the Criteria Performance Report.

https://developers.google.com/adwords/api/docs/appendix/reports#click

Upvotes: 0

Views: 3425

Answers (3)

Roger W.
Roger W.

Reputation: 165

From the documentation fro the Click Performance Report (https://developers.google.com/adwords/api/docs/appendix/reports/click-performance-report):

"Note: This report can be run only for a single day and only for dates up to 90 days before the time of the request."

So, I imagine you can't select the Date field, because it is implied by the single date you must filter by.

I know it's late, and you've probably moved on, but maybe this will help someone else with the same issue.

Upvotes: 0

ratiorick
ratiorick

Reputation: 746

The issue is with your predicate - AS "click performance report" does not have a 'status' field - so remove that predicate - that is most likely your problem -

also remove the $reportDefinition->includeZeroImpressions = FALSE; You don't need this since this is a click performance report -

and the date field is a segment - if the above does not work , then maybe try to add at least an attribute , like GclId or something -

Since this report can only be run for one day , it seems silly to just be selecting the date.

Hope this helps -

See this link for reporting fields - if you plan on running a variety of reports you will find this link very useful

https://developers.google.com/adwords/api/docs/appendix/reports#click

Upvotes: 1

noelnoegdip
noelnoegdip

Reputation: 531

Is there not a little bit more info after that error such as Trigger = 'status' or something? That will often tell you what column is causing the error.

If that does not help then run the GetReportFields.php file to see a list of the names and check they match the ones you are trying to use.

Also the names do change between versions so the example they show might only have names that work in the v201402 version and maybe you are trying the v201309 version. I had this issue and once I used the new library it was fixed.

Upvotes: 0

Related Questions