Google Ad Manager API 报表查询
Google Ad Manager API Report Querying
Google 有以下广告管理器 here 的文档。不幸的是他们的例子:
# 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'.
显然这个例子是错误的,这个例子的正确语法是:
'startDate': {
'year': 2021,
'month': 3,
'day': 1
},
https://github.com/googleads/googleads-python-lib/issues/475#issuecomment-821209008
Google 有以下广告管理器 here 的文档。不幸的是他们的例子:
# 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'.
显然这个例子是错误的,这个例子的正确语法是:
'startDate': {
'year': 2021,
'month': 3,
'day': 1
},
https://github.com/googleads/googleads-python-lib/issues/475#issuecomment-821209008