简体   繁体   English

AdWords API PHP-点击效果报告

[英]AdWords API PHP - Click Performance Report

I am trying to download a click performance report from the AdWords-API. 我正在尝试从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". 我得到的错误是:“ ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT”。 The same script runs with no problems for the Criteria Performance Report. 对于Criteria Performance Report,相同的脚本运行没有问题。

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

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 - 问题与您的谓词有关-AS“点击效果报告”没有“状态”字段-因此请删除该谓词-这很可能是您的问题-

also remove the $reportDefinition->includeZeroImpressions = FALSE; 还删除$ 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 - 并且date字段是一个细分-如果上述方法无效,则可能尝试至少添加一个属性,例如GclId或其他内容-

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 https://developers.google.com/adwords/api/docs/appendix/reports#click

Is there not a little bit more info after that error such as Trigger = 'status' or something? 该错误发生后是否没有更多信息,例如Trigger ='status'或其他内容? 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. 如果这样做没有帮助,请运行GetReportFields.php文件以查看名称列表,并检查它们是否与您要使用的名称匹配。

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. 此外,名称也会在版本之间更改,因此它们显示的示例可能仅具有适用于v201402版本的名称,并且您可能正在尝试使用v201309版本。 I had this issue and once I used the new library it was fixed. 我遇到了这个问题,一旦我使用了新库,它就被修复了。

From the documentation fro the Click Performance Report ( https://developers.google.com/adwords/api/docs/appendix/reports/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." “注意:此报告只能运行一天,并且只能运行在请求时间之前90天之内的日期。”

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. 我知道已经很晚了,您可能已经继续前进,但这也许可以帮助遇到相同问题的其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM