【问题标题】:How to get the total clicks on google ad?如何获得谷歌广告的总点击次数?
【发布时间】:2015-07-10 06:39:42
【问题描述】:

我正在使用 php 来获取每个关键字在 Google adwords 中的广告系列的总数。我已经设置了所有但问题是我正在下载的报告不包含数据。

我获取报告的功能:

function DownloadKeywordReport(AdWordsUser $user, $filePath, $keyword_id) 
    {
        // Load the service, so that the required classes are 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 that haven't recieved any impressions over the date range.
        $reportDefinition->includeZeroImpressions = FALSE;

        // Set additional options.
        $options = array('returnMoneyInMicros' => FALSE);

        ReportUtils::DownloadReport($reportDefinition, $filePath, $user, $options);
        printf("Report with name '%s' was downloaded to '%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");

    }

生成的xml报告是

<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>

如果我使用 google adsense 预览工具,它不会在此处显示我的添加。我做错了什么或者测试帐户有什么可能性?

【问题讨论】:

    标签: php adsense google-ads-api google-ad-manager


    【解决方案1】:

    测试帐户不会累积展示次数(因为没有显示广告),因此您需要设置

    $reportDefinition-&gt;includeZeroImpressions = TRUE;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多