Testing modes
Stay organized with collections
Save and categorize content based on your preferences.
Test adBreak() integration
In order to test JavaScript code that uses the adBreak()
API we provide a
testing mode that can be enabled by adding data-adbreak-test="on"
attribute on
the adsbygoogle.js
:
<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>
Testing mode:
- Displays mock ads instead of requesting real ads.
- Mimics real ads behaviour such as respecting your configured ad frequency.
- Use
console.log
or
break points
to debug
adBreakDone()
and placementInfo
.
Note: testing mode only allows you to test
client-side JavaScript without sending ad requests to Google servers. It can't
help you to detect issues related to misconfiguration of the AdSense code such
as invalid `data-ad-client` values.
Test mode cycles between two scenarios: ad is loaded and ad is not loaded to
emulate a real environment where ad will not always be available.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-02-21 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-02-21 UTC."],[[["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."]]],[]]