获取多个广告系列统计信息Google Ads

时间:2019-05-11 21:22:40

标签: php google-ads-api

我正在尝试获取Google Ads报告,但是遇到问题并且需要帮助。

目前,我可以获取ACCOUNT(在某个日期显示为分组数据)或CAMPAIGN(每个日期显示每个单独的广告系列的每个值)级别的数据。

我需要输入的是一组广告系列(3个广告系列),输出是带有点击率的日期列表。

输入:111111111,2222222222,333333333 输出: 1-1-2019:点击率:2% 2-1-2019:点击率:2% 3-1-2019:点阅率:2% ...

我有这个,你能帮我吗?预先感谢

    $query = (new ReportQueryBuilder())
        ->select([
            'Date',
            'ctr'
        ])
        ->from(ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT)
        ->duringDateRange(ReportDefinitionDateRangeType::LAST_7_DAYS)
        ->build();
    // Download report as a string.
    $reportDownloader = new ReportDownloader($session);
    $reportSettingsOverride = (new ReportSettingsBuilder())->includeZeroImpressions(false)->build();

    $reportDownloadResult = $reportDownloader->downloadReportWithAwql(
        sprintf('%s', $query),
        $reportFormat,
        $reportSettingsOverride
    );
    //print "Report was downloaded and printed below:\n";
    $datos = $reportDownloadResult->getAsString();
    return ($datos);
}
public static function main(){
    $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();
    $session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->build();
    $string = self::runExample($session, DownloadFormat::XML);
    $xml = new \SimpleXMLElement($string);
    return $xml;}}

0 个答案:

没有答案