Ad monetisation guide
This guide shows how to place midgame ads, rewarded ads and banners so that revenue grows without costing you players. The binding rules are in the advertisement rules; this page is how to do well inside them. Examples assume const SDK = window.ZokoGames.SDK; and await SDK.init(); as in the SDK introduction. Unfamiliar terms are in the glossary.
When ads run#
- Full launch only. Ads are off during basic launch, for kids games and for players who are ad-free members. Build the integration during basic launch anyway. Until ads are live,
SDK.ad.requestAdfails withadsDisabled, so the error path below is the code that runs, and you can test it today. In full launch the ads shown today are the portal's own house ads: no ad network is connected yet, so they earn no revenue (see feature status). - Local mode (your own
localhostpage):requestAdshows a black "Local ad" overlay for three seconds, then callsadFinished. Midgame ads honour the three-minute cooldown (a second midgame request inside it fails withadCooldown). Since SDK 1.6.4 local mode refuses a midgame request made beforegameplayStart()too, like the portal (see below). Banners appear as grey dashed boxes. Add?ad_response=unfilled,adblock,adsDisabledorotherto the page address to force each failure. - Ad-blocked players and players who close an ad:
requestAdcallsadErrorwith a code such asadblockorunfilled. A rewarded ad the player closes early also ends inadError, with no reward.
A design that earns today and loses players next week earns less in total. These patterns respect both. For where each format fits in action, clicker, driving, io, idle, puzzle and word games, see monetisation by genre.
Midgame ads#
Choose the breaks#
Good: end of a level, return to the menu, after a game-over screen has been read, after a shop closes. Bad: right after a death in the middle of a streak, when the player just opened the game, on any button players press repeatedly.
Start gameplay first#
Call SDK.game.gameplayStart() when the player starts to play. Until your game has called it once, the portal refuses every midgame request with adCooldown and the message "Midgame ads are available after gameplay starts: call game.gameplayStart() first". A game that never calls it gets midgame ads 30 seconds after play begins. Rewarded ads are not affected. Local mode shows this refusal from SDK 1.6.4; with 1.6.3 and earlier you saw it only on the site and in the Preview tool.
Pace them#
The portal allows one midgame ad every three minutes, and any ad (rewarded too) restarts that timer. Rewarded ads themselves are not held back by it. Do not try to hit exactly that:
- Make the first ad later than the cooldown, once the player has played a round. Players who see an ad in the first thirty seconds leave more.
- Count breaks (levels, runs), not seconds, and show an ad every second or third break.
- If a request fails (
unfilled,adCooldown,adblock,adsDisabled), just continue. Do not retry immediately. An admin can also set a longer minimum gap or a cap per session for your game, which shows up asadCooldowntoo, and so does a request made beforegameplayStart().
let breaks = 0;
async function showMidgame() {
await SDK.ad.requestAd("midgame", {
adStarted: () => { pauseAll(); }, // pause game and mute here
adFinished: () => {}, // nothing to do: we resume below
adError: () => {}, // no fill, cooldown, adblock, ads off: carry on
});
resumeAll(); // runs after finish or error; the promise resolves in both cases
}
async function onLevelEnd() {
await SDK.game.gameplayStop();
breaks++;
if (breaks % 2 === 0) await showMidgame();
showLevelSummary();
}pauseAll, resumeAll and showLevelSummary are your own functions. requestAd resolves once the ad has finished or failed, and never rejects for an ad outcome (it rejects only for bad arguments or a disabled SDK).
Be clean#
Block clicks while the request is pending, pause and mute in adStarted, and resume on both adFinished and adError. After resuming, return focus to the game.
Rewarded ads#
Rewarded ads convert when the reward is obviously worth thirty seconds.
- Offer, don't push. Show the button on a screen where the player is already deciding: results screen ("double your coins"), a shop, or a continue screen.
- Be explicit. Name the reward on the button. Mark it as an ad.
- Always provide a no-ad route to the same reward, even if slower or smaller.
- Reward only after
adFinished. OnadErrorshow a friendly message and no reward. - Limit frequency. Cap how many rewards can be claimed per session or per timer. Rewards that never run out devalue themselves.
- Don't stack. No midgame ad directly followed by a rewarded offer between the same two levels.
async function onDoubleCoins() {
let ok = false;
await SDK.ad.requestAd("rewarded", {
adStarted: pauseAll,
adFinished: () => { ok = true; },
adError: (e) => console.warn("rewarded ad failed:", e.code),
});
resumeAll();
if (ok) addCoins(runCoins); else toast("No ad available right now");
}Only one ad can run at a time: a second requestAd while one is on screen calls its adError at once.
Banners#
- Only on screens that stay open at least about five seconds: menus, level select, results.
- Never over the playfield or over a control.
- Clear them before gameplay (
clearAllBanners). - Do not request again inside 30 seconds; each container can refresh once per 30 seconds and a session has a cap of 60 refreshes.
- Banner requests while a video ad is on screen fail with
videoAdPlaying; request them again afteradFinished. - Make the layout work without a banner; they can fail or be disabled.
Banner calls reject with an error object (code, message, containerId) instead of calling a callback, so wrap them. The container must be an element that is on screen with a real size:
// <div id="menu-banner" style="width:100%;height:100px"></div>
try {
await SDK.banner.requestResponsiveBanner("menu-banner");
} catch (e) {
// bannersDisabled (ads off, kids, ad-free), notVisible, videoAdPlaying, bannerCooldown, ...
console.warn("no banner:", e.code);
}
// leaving the menu:
await SDK.banner.clearAllBanners();In local mode you see a grey dashed placeholder inside the container; anywhere else nothing appears until your game is in full launch.
When to show what#
| Moment | Midgame | Rewarded | Banner |
|---|---|---|---|
| First 30 seconds of a first session | No | No | No |
| During active play | Never | Never | Never |
| Level or round complete, results read | Yes, every second or third break | Offer "double it" | Yes, on the results screen |
| Death or fail screen | After the screen was read, not instantly | "Continue" offer with a no-ad route | Yes |
| Shop, upgrade or pause menu | No | Offer a reward tied to what the player is looking at | Yes |
| Returning to the main menu | Yes, if the cooldown allows | Optional daily bonus | Yes |
| Loading screens | No | No | No |
The starter kits implement exactly this pattern.
Measure#
- Watch session length and retention alongside revenue in the console. If a change raises ad frequency and lowers day-1 retention, undo it.
- Change one thing at a time and give it a few days of traffic.
Adblock players#
They are still players. await SDK.ad.hasAdblock() resolves true when a blocker is detected (and false in kids mode, where no ad script loads). Hide the rewarded button or offer the alternative route to the same reward, and do not shame them. A midgame ad that a blocker stops simply reaches adError with adblock; carry on.