測試模式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
測試 adBreak() 整合
如要測試使用 adBreak() API 的 JavaScript 程式碼,我們提供測試模式,只要在 adsbygoogle.js 上新增 data-adbreak-test="on" 屬性即可啟用:
<script async
data-adbreak-test="on"
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456789"
crossorigin="anonymous">
</script>
<script>
window.adsbygoogle = window.adsbygoogle || [];
var adBreak = adConfig = function(o) {adsbygoogle.push(o);}
</script>
測試模式:
- 顯示模擬廣告,而非請求實際廣告。
- 模擬實際廣告行為,例如遵守您設定的廣告頻率。
- 使用
console.log 或
中斷點
偵錯
adBreakDone()
和 placementInfo。
注意:測試模式只允許您測試用戶端 JavaScript,不會將廣告請求傳送至 Google 伺服器。但無法協助您偵測 AdSense 程式碼設定錯誤相關問題,例如無效的 `data-ad-client` 值。
測試模式會在兩種情境之間循環切換:載入廣告和未載入廣告,模擬廣告不一定可用的真實環境。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],["To test `adBreak()` API integration, enable testing mode by adding `data-adbreak-test=\"on\"` to the `adsbygoogle.js` script. This mode displays mock ads, mimicking real ad behavior, but does not send real ad requests. It cycles between ad loaded and not loaded scenarios. Use `console.log` or breakpoints to debug `adBreakDone()` and `placementInfo`. This method helps test client-side JavaScript, but it cannot detect issues related to AdSense code misconfiguration.\n"]]