Skip to main content

Interstitial Ads

Interstitial ad units show full-page ads in your app. Place them at natural breaks & transitions in your app's interface, such as after level completion in a gaming app.

Benefits of Interstitial Ads

  • Engaging content
  • Full-screen size
  • Media content can be static, video-based or interactive
  • Positive UX
  • Placement in natural transition points improves overall user experience (UX)
caution

You should finish these steps before releasing.

Load the ad

Yodo1U3dInterstitialAd.GetInstance().LoadAd();
Setup the auto delay load

Loading a new ad from OnAdLoadFailedEvent() without delay is not recommended. If a new ad needs to be loaded immediately on OnAdLoadFailedEvent(), then the auto delay config variable must be set to true to limit ad load retries to avoid continuous failed ad requests to avoid ANR issues.

// Remember to call this function before SDK init.
Yodo1U3dInterstitialAd.GetInstance().autoDelayIfLoadFail = true;

Display the ad

bool isLoaded = Yodo1U3dInterstitialAd.GetInstance().IsLoaded();

// Show ad with placement name, like app_start, level_end
if (isLoaded)
{
Yodo1U3dInterstitialAd.GetInstance().ShowAd("Your Placement Id");
}

// Show ad without placement name
if (isLoaded)
{
Yodo1U3dInterstitialAd.GetInstance().ShowAd();
}

Configure the ad events

The MAS SDK fires several events to inform you of ad availability.

using Yodo1.MAS;

public class InterstitialAdLoader : MonoBehaviour
{
private int retryAttempt = 0;

private void Start()
{
SetupEventCallbacks();
LoadInterstitialAd();
}

private void SetupEventCallbacks()
{
Yodo1U3dInterstitialAd.GetInstance().OnAdLoadedEvent += OnInterstitialAdLoadedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdLoadFailedEvent += OnInterstitialAdLoadFailedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdOpenedEvent += OnInterstitialAdOpenedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdOpenFailedEvent += OnInterstitialAdOpenFailedEvent;
Yodo1U3dInterstitialAd.GetInstance().OnAdClosedEvent += OnInterstitialAdClosedEvent;
}

private void LoadInterstitialAd()
{
Yodo1U3dInterstitialAd.GetInstance().LoadAd();
}

private void OnInterstitialAdLoadedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when an ad finishes loading.
retryAttempt = 0;
Yodo1U3dInterstitialAd.GetInstance().ShowAd();
}

private void OnInterstitialAdLoadFailedEvent(Yodo1U3dInterstitialAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad request fails.
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadInterstitialAd", (float) retryDelay);
}

private void OnInterstitialAdOpenedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when an ad opened
}

private void OnInterstitialAdOpenFailedEvent(Yodo1U3dInterstitialAd ad, Yodo1U3dAdError adError)
{
// Code to be executed when an ad open fails.
LoadInterstitialAd();
}

private void OnInterstitialAdClosedEvent(Yodo1U3dInterstitialAd ad)
{
// Code to be executed when the ad closed
LoadInterstitialAd();
}
}

Video Tutorial

Best Practices

1. Preload

We recommend that you preload the interstitial ad before showing it. This will ensure the ad is ready to be displayed when needed.

2. Placement

We recommend setting the placement name when you show the ad. This will help you track each placement's performance in the dashboard.

3. Handle Failures

If the ad fails to load, you should NOT try to reload immediately. Instead, it would be best if you waited a while before reloading the ad again. We recommend waiting at least 10 seconds before trying to fill the ad.