Shift2App
Home chevron_right Advertisements
payments

Advertisements

Monetize your app with Google AdMob

Overview

Ad types available

warning
AdMob Required

Enable AdMob in your dashboard and configure your App ID and Ad Unit IDs.

web_asset

Banner Ads

Small ads at screen edge. Non-intrusive.

fullscreen

Interstitial Ads

Full-screen ads at transition points.

play_circle

Rewarded Ads

Users watch for rewards. Highest revenue.

shift2appjs.showBannerAd()

Displays banner ad at configured position (top or bottom).

Returns

void

javascript
// Show banner on page load
if (typeof shift2appjs !== "undefined") {
    shift2appjs.showBannerAd();
}
shift2appjs.hideBannerAd()

Hides the banner ad.

Returns

void

javascript
// Hide on checkout pages
if (location.pathname.includes("/checkout")) {
    shift2appjs.hideBannerAd();
}

Interstitial Ads

Full-screen ads

shift2appjs.showInterstitialAd(callbackName)

Shows full-screen interstitial ad. Callback invoked when closed.

Parameters
callbackName String - Global function name to call when ad closes
Returns

void

javascript
// Define callback
function onAdClosed(shown) {
    console.log(shown ? "Ad shown" : "Ad failed");
    loadNextPage();
}

// Show ad
shift2appjs.showInterstitialAd("onAdClosed");
shift2appjs.isInterstitialAdReady()

Checks if an interstitial ad is loaded and ready.

Returns

Boolean - true if ready

javascript
// Only show if ready
if (shift2appjs.isInterstitialAdReady()) {
    shift2appjs.showInterstitialAd("onAdClosed");
} else {
    loadNextPage(); // Skip ad
}

Rewarded Ads

Users watch for rewards

shift2appjs.showRewardedAd(callbackName)

Shows rewarded video ad. Callback receives reward info when user finishes watching.

Parameters
callbackName String - Global function to receive reward data
Returns

void

javascript
// Define reward callback
function onRewardEarned(success, amount, type) {
    if (success) {
        alert("You earned " + amount + " " + type + "!");
        addCoinsToUser(amount);
    } else {
        alert("Watch complete video for reward!");
    }
}

// Offer to user
if (shift2appjs.isRewardedAdReady()) {
    if (confirm("Watch video for 50 coins?")) {
        shift2appjs.showRewardedAd("onRewardEarned");
    }
}
shift2appjs.isRewardedAdReady()

Checks if a rewarded ad is loaded and ready.

Returns

Boolean - true if ready

javascript
// Update button state
function updateRewardButton() {
    const btn = document.getElementById("watchAdBtn");
    btn.disabled = !shift2appjs.isRewardedAdReady();
    btn.textContent = btn.disabled ? "Loading..." : "Watch Ad for Coins";
}
setInterval(updateRewardButton, 5000);

Best Practices

check_circle
Show ads at natural breaks

Between articles, levels, or after completing actions.

check_circle
Give meaningful rewards

Coins, extra features, or premium content users actually want.

close
Don't spam interstitials

Limit to once every 2-3 minutes. Users will uninstall if annoyed.

close
Don't force rewarded ads

Always make them optional. Users should choose to watch.

dashboard Dashboard menu_book Docs science Playground