首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google Ad Manager API报告查询

Google Ad Manager API报告查询
EN

Stack Overflow用户
提问于 2020-10-08 02:45:45
回答 1查看 308关注 0票数 0

谷歌为广告管理器here提供了以下文档。不幸的是,他们的例子:

代码语言:javascript
运行
复制
# Set the start and end dates of the report to run (past 8 days).
end_date = date.today()
start_date = end_date - timedelta(days=8)

# Create report job.
report_job = {
    'reportQuery': {
        'dimensions': ['LINE_ITEM_ID', 'LINE_ITEM_NAME'],
        'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS',
                    'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE',
                    'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'],
        'dateRangeType': 'CUSTOM_DATE',
        'startDate': start_date,
        'endDate': end_date
    }
}

# Initialize a DataDownloader.
report_downloader = client.GetDataDownloader(version='v202008')

try:
  # Run the report and wait for it to finish.
  report_job_id = report_downloader.WaitForReport(report_job)
except errors.AdManagerReportError as e:
  print('Failed to generate report. Error was: %s' % e)

with tempfile.NamedTemporaryFile(
    suffix='.csv.gz', mode='wb', delete=False) as report_file:
  # Download report data.
  report_downloader.DownloadReportToFile(
      report_job_id, 'CSV_DUMP', report_file)

report_job_id行上生成一个KeyError: 'date'。我的授权是正确的,我可以与我的客户进行其他呼叫。我的问题是,如何更新report_job才能使示例正常工作。我尝试更改'dateRangeType',但是this声明它必须是'CUSTOM_DATE‘。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-06 10:09:10

显然,这个例子是错误的,正确的语法是:

代码语言:javascript
运行
复制
'startDate': {
    'year': 2021,
    'month': 3,
    'day': 1
},

https://github.com/googleads/googleads-python-lib/issues/475#issuecomment-821209008

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64250423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档