常見問題
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 發布商可隨時變更時區,這可能會導致報表數據起伏。詳情請參閱「當地時區報表」指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-08-22 (世界標準時間)。
[null,null,["上次更新時間: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"]]