測試模式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
測試 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>
測試模式:
- 停用某些會使本機測試難以實行的保護措施,例如展示頻率上限。
- 顯示模擬廣告,而非請求實際廣告。
注意:測試模式僅允許您測試用戶端 JavaScript,而不必傳送廣告請求給 Google 伺服器。這項工具可協助偵測與 AdSense 程式碼設定錯誤相關的問題,例如無效的「data-ad-client」值。
兩個情境之間的測試模式週期:廣告載入完成且廣告無法載入,以模擬廣告不一定都能使用的實際環境。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2023-10-31 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2023-10-31 (世界標準時間)。"],[[["Testing mode for `adBreak()` is enabled by adding `data-adbreak-test=\"on\"` to the `adsbygoogle.js` script tag."],["This mode displays mock ads, mimics real ad behavior (like frequency capping), and allows debugging with `console.log` or breakpoints."],["It's for testing client-side JavaScript only and doesn't detect AdSense code misconfigurations."],["The test mode cycles between scenarios where ads are and aren't loaded to simulate real-world conditions."]]],["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"]]