常见误区
AdSense Management API 提供用于生成新的和已保存的报告的调用。这些报告可以包含简单的分析结果(例如每日收入),也可以包含非常复杂的表格,其中包含每个国家/地区每个自定义渠道的点击率。本指南介绍了一系列应正确处理的极端情况,以实现与 API 的强大集成。
报告结构
报告结果以 ReportResult
对象的形式返回。如需了解完整详细信息,请参阅报告响应参考文档。
使用按时间顺序的维度:DATE、WEEK 和 MONTH
报告可以为空或有缺漏
如果在请求中指定的时间段内没有任何活动,则系统不会生成广告请求,并且报告服务不会显示这些时间段内的行。绘制图表时,这一点很重要。
如需了解详情,请参阅日期填充指南。
在同一报告中请求 MONTH 和 WEEK 维度
该报告可能会造成负面或意想不到的后果。如果某一周属于两个不同的月份,则该周会显示两行,每行对应一个月份。
示例
维度 | 指标 | 开始日期 | 结束日期 |
WEEK
MONTH |
CLICKS | 2014-04-28 |
2014-05-03 |
返回:
MONTH | WEEK * | CLICKS |
2014-04 |
2014-04-27 |
50 |
2014-05 |
2014-04-27 |
43 |
* 一周的第一天
解决方案
从报告中移除“MONTH
”。
整理维度值
请求与平台(桌面设备、高端移动设备等)相关的维度时,将仅显示发生活动的平台。如果给定的日期、周或月没有来自高端移动设备的访问,则不会显示该类别的信息。
示例
维度 | 指标 | 开始日期 | 结束日期 |
PLATFORM_TYPE_NAME
MONTH |
AD_REQUESTS |
2014-02-01 | 2014-03-31 |
返回:
月 | PLATFORM_TYPE_NAME | AD_REQUESTS |
2014-03 |
桌面版 |
100 |
2014-03 |
高端移动设备 |
5 |
2014-04 |
桌面版 |
75 |
解决方案
处理报告结果时,假定结果中未显示的所有维度值均为零:
月 | PLATFORM_TYPE_NAME | AD_REQUESTS |
2014-03 |
桌面版 |
100 |
2014-03 |
高端移动设备 |
5 |
2014-04 |
桌面版 |
75 |
2014-04 |
高端移动设备 |
0 |
合并多个连续报告
有时,报告过大,无法一次性生成,必须进行批量处理。如果您的应用会执行此操作,请考虑以下情况:
- 如果您使用的是
WEEK
或 MONTH
维度,并在一周或月中间对报告进行拆分,则每个报告都会包含包含不同数据的重复条目。
- 确保所有报告都具有相同的指标和维度,因为使用不同的维度可能无法合并数据。
特殊账号
您的部分用户的 AdSense 帐号可能带有您意想不到或不了解的属性。请务必考虑以下因素:
- 拥有数千个域名或网站的发布商
- 拥有数千个广告单元或自定义渠道的发布商
- 想要为多个广告客户(AdSense 搜索广告、AdSense 视频广告等)生成报告的发布商
多个账号
用户可以访问多个 AdSense 帐号。因此,每次调用该 API 时都必须指定帐号 ID。调用 accounts.list
会获取帐号列表,并且系统应向用户显示帐号选择器对话框。如果提取的帐号数为一个,则可以绕过该错误。
时区更改
AdSense 发布商可以随时更改时区,这可能会导致报告中出现高峰或低谷。如需了解详情,请参阅有关本地时区报告的指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-22。
[null,null,["最后更新时间 (UTC):2024-08-22。"],[[["The AdSense Management API allows for the generation of reports with varying levels of complexity, ranging from basic earnings data to detailed click-through rates across dimensions like custom channels and countries."],["When generating reports, be aware of potential edge cases like empty reports, gaps in data for inactive periods, and unexpected results when combining certain dimensions like `WEEK` and `MONTH`."],["Ensure accurate report interpretation by accounting for missing dimension values, which should be treated as zero, and be cautious when combining multiple reports to avoid data duplication or incompatibility."],["Consider special scenarios, such as publishers with numerous domains, ad units, or custom channels, and accommodate users with multiple AdSense accounts by implementing account selection."],["Account for potential data fluctuations due to AdSense publisher timezone changes, which can impact report accuracy."]]],["The AdSense Management API allows generating reports with diverse analytics. Key considerations for integration include handling empty reports or gaps if there's no activity. Requesting `MONTH` and `WEEK` dimensions together can cause duplicate rows. When collating dimensions like platforms, assume zero for missing values. Combining large reports can create duplicate entries if split mid-week or month. Also, account for special user types with numerous domains, ad units, or multiple ad clients and time zone changes. Every call needs an account ID.\n"]]