dousheng3364 2015-07-10 06:39
浏览 90

如何获得Google广告的总点击次数?

I am using the php to get the total count on a campaign in the Google adwords for each keyword. I have setup all But the issue is the report I am downloading does't contain the data.

my function to get report:

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'.
",
        $reportDefinition->reportName, $filePath);


        $doc = new DOMDocument();
        $doc->loadXML(file_get_contents($filePath));
        $xp = new DOMXPath($doc);
        $q = $xp->query("/report/table/row/@cost");

    }

and the xml report generated is

<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 I use google adsense preview tool it is not showing my adds here. Am i doing something wrong or what are the possibilities with a test account?

  • 写回答

1条回答 默认 最新

  • dongyiyu882684 2015-07-13 17:25
    关注

    A test account doesn't accumulate impressions (as the ads are not being shown), thus you'll need to set

    $reportDefinition->includeZeroImpressions = TRUE;

    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据