Fallback Solution (beta)
The ad backfill mechanism helps maximize revenue by filling unsold impressions. Whenever an ad request through the platform SDK fails, you can display ads using Playgama Ads.
Supported Platforms:
Beta Access
Playgama Ads is currently available in closed beta.
To request access, please contact us at [email protected].
If you are using Playgama Bridge
The backfill mechanism is already built in. All you need to do is provide your IDs in the config, and everything will run automatically.
If you're not using Playgama Bridge
You will need to implement this logic yourself. To see an example of how it works, you can check the Playgama Bridge source code.
Installation
<script src="https://playgama.com/ads/msn.v0.1.js"></script>
// Initialize the SDK
await window.pgAds.init('<your-clid>');
window.pgAds.updateTargeting({ gameId: '<game-identifier>' });
Show Interstitial
window.$msstart.loadAdsAsync(false)
.then((msnAd) => window.$msstart.showAdsAsync(msnAd.instanceId))
.catch(() => {
const playgamaAd = await window.pgAds.requestOutOfPageAd('interstitial');
if (playgamaAd.state === 'ready') {
playgamaAd.show();
} else {
playgamaAd.addEventListener('ready', () => {
playgamaAd.show();
});
}
});
Show Rewarded
window.$msstart.loadAdsAsync(true)
.then((msnAd) => window.$msstart.showAdsAsync(msnAd.instanceId))
.catch(() => {
const playgamaAd = await window.pgAds.requestOutOfPageAd('rewarded');
if (playgamaAd.state === 'ready') {
playgamaAd.show();
} else {
playgamaAd.addEventListener('ready', () => {
playgamaAd.show();
});
}
playgamaAd.addEventListener('rewarded', () => {
console.log('Grant reward to user');
});
});
Last updated