簡體   English   中英

AdWords API PHP-點擊效果報告

[英]AdWords API PHP - Click Performance Report

我正在嘗試從AdWords-API下載點擊效果報告。 對於我的示例,我僅選擇“日期”字段。

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);
}

我得到的錯誤是:“ ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT”。 對於Criteria Performance Report,相同的腳本運行沒有問題。

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

問題與您的謂詞有關-AS“點擊效果報告”沒有“狀態”字段-因此請刪除該謂詞-這很可能是您的問題-

還刪除$ reportDefinition-> includeZeroImpressions = FALSE; 您不需要這個,因為這是點擊效果報告-

並且date字段是一個細分-如果上述方法無效,則可能嘗試至少添加一個屬性,例如GclId或其他內容-

由於此報告只能運行一天,因此僅選擇日期似乎很愚蠢。

希望這可以幫助 -

請參閱此鏈接以獲取報告字段-如果您計划運行各種報告,則會發現此鏈接非常有用

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

該錯誤發生后是否沒有更多信息,例如Trigger ='status'或其他內容? 這通常會告訴您導致錯誤的列。

如果這樣做沒有幫助,請運行GetReportFields.php文件以查看名稱列表,並檢查它們是否與您要使用的名稱匹配。

此外,名稱也會在版本之間更改,因此它們顯示的示例可能僅具有適用於v201402版本的名稱,並且您可能正在嘗試使用v201309版本。 我遇到了這個問題,一旦我使用了新庫,它就被修復了。

在文檔中,點擊效果報告( https://developers.google.com/adwords/api/docs/appendix/reports/click-performance-report ):

“注意:此報告只能運行一天,並且只能運行在請求時間之前90天之內的日期。”

因此,我想您無法選擇“日期”字段,因為它必須由您篩選的單個日期隱含。

我知道已經很晚了,您可能已經繼續前進,但這也許可以幫助遇到相同問題的其他人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM