Docs menu Ad Placement API
Google's Ad Placement API
Last updated 2026-11-19
Games built for Google’s Ad Placement API (also called H5 Games Ads) call adBreak() and adConfig(). The FreeGames.gg SDK script sets up both, so you keep those calls and only change the scripts.
Swap the scripts
Remove Google’s ad script. Your game MUST NOT load it (the no_ad_scripts check fails):
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-..." data-adbreak-test="on"></script>Add ours before your game’s scripts:
<script src="https://games.foony.com/sdk/v1.js"></script>You can keep Google’s usual set-up lines. They work before or after our script:
<script>
window.adsbygoogle = window.adsbygoogle || [];
var adBreak = adConfig = function (options) {
adsbygoogle.push(options);
};
</script>Calls pushed before our script loaded run once it does.
How each break type runs
type |
Runs | adBreakDone gets breakStatus |
|---|---|---|
'start', 'pause', 'next', 'browse' |
commercialBreak() |
viewed when an ad showed, else frequencyCapped |
'preroll' |
commercialBreak() |
Almost always frequencyCapped: the first game of a visit has no interstitial |
'reward' |
rewardedBreak() |
viewed, dismissed (closed early) or notReady (no ad) |
beforeAd() runs when an ad starts, and afterAd() after it, only when one showed.
Rewarded breaks
adBreak({
type: 'reward',
name: 'extra-life',
beforeReward: (showAdFn) => showWatchAdButton(showAdFn),
adViewed: () => giveExtraLife(),
adDismissed: () => showMessage('No reward this time.'),
adBreakDone: () => hideWatchAdButton(),
});Google calls beforeReward only when an ad is ready. Here it is always called, since the page can’t know before it asks. When the player presses your button and no ad comes, your game gets adDismissed() and breakStatus notReady. Treat it as “no reward” and go on.
adConfig
adConfig({onReady}) calls onReady once the SDK has started. preloadAdBreaks and sound are ignored. The page preloads ads itself, and you get sound changes from audio.onMuteChange (see the SDK reference).
Still call the gameplay events
The Ad Placement API has no loading or gameplay events. Add FreeGamesSdk.loadingFinished(), gameplayStart() and gameplayStop(): the loading_finished and gameplay_start checks are MUST checks.