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."],[],["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"]]