Skip to content

Interstitial ads

Interstitial ads are full-screen or full-page ads that temporarily cover an app’s interface. They’re typically shown at natural pauses or transition points—such as after completing a level in a game or when navigating between major views.

The following sections show you how to load and then show an interstitial ad.

Loading an interstitial ad

The following code shows you how to attach event listeners and load the first interstitial:

var INTERSTITIAL_AD_UNIT_ID;
if (window.cordova.platformId.toUpperCase() === 'IOS') {
INTERSTITIAL_AD_UNIT_ID = '«iOS-ad-unit-ID»';
} else {
// Assume Android
INTERSTITIAL_AD_UNIT_ID = '«Android-ad-unit-ID»';
}
var retryAttempt = 0;
function initializeInterstitialAds()
{
window.addEventListener('OnInterstitialLoadedEvent', function (adInfo) {
// Interstitial ad is ready to show. AppLovinMAX.isInterstitialReady(INTERSTITIAL_AD_UNIT_ID) now returns 'true'
// Reset retry attempt
retryAttempt = 0;
});
window.addEventListener('OnInterstitialLoadFailedEvent', function (adInfo) {
// Interstitial ad failed to load
// AppLovin recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds)
retryAttempt++;
var retryDelay = Math.pow(2, Math.min(6, retryAttempt));
setTimeout(function () {
loadInterstitial();
}, retryDelay * 1000);
});
window.addEventListener('OnInterstitialClickedEvent', function (adInfo) {});
window.addEventListener('OnInterstitialDisplayedEvent', function (adInfo) {});
window.addEventListener('OnInterstitialAdFailedToDisplayEvent', function (adInfo) {
// Interstitial ad failed to display. AppLovin recommends that you load the next ad.
loadInterstitial();
});
window.addEventListener('OnInterstitialHiddenEvent', function (adInfo) {
// Interstitial ad is hidden. Pre-load the next ad.
loadInterstitial();
});
// Load the first interstitial
loadInterstitial();
}
function loadInterstitial()
{
AppLovinMAX.loadInterstitial(INTERSTITIAL_AD_UNIT_ID);
}

Showing an interstitial ad

To show an interstitial ad, call showInterstitial():

if (AppLovinMAX.isInterstitialReady(«ad-unit-ID»))
{
AppLovinMAX.showInterstitial(«ad-unit-ID»);
}