Interstitial Ads - cleveradssolutions/CAS-Unreal GitHub Wiki
Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.
flowchart TD
A[Autoload] -->|auto| L((Load))
L -->|success| R([OnAdLoaded])
L -->|fail| F([OnAdLoadFailed])
F -->|delay| A
R --> RL[IsAdReady]
S((Show)) --> RL
RL -->|success| SR([OnAdDisplayed])
RL -->|fail| SF([OnAdShowFailed])
SR --> I([OnAdsImpression])
SR --> C([OnAdClicked])
I --> D([OnAdDismissed])
D --> A
SF --> A
Load an Ad
Call manual load ad before each show if Autoload Interstitial Ads
not checked.
In Blueprints you can use Load node just for register Loaded/Failed events.
UCASMobileAds::LoadInterstitialAd();
[!NOTE]
TheEvent Once
checkbox will fire the Loaded/Failed event only once. ifAutoload Ads
used, events can be triggered many times while the game world exists.
Autoload mode
If enabled, the ad will automatically load new content when the current ad is dismissed or completed. Additionally, it will automatically retry loading the ad if an error occurs during the loading process.
UCASMobileAds::SetAutoloadInterstitialAd(true);
You should call LoadInterstitialAd()
once to create Ad Instance.
By default, autoloading is defined in the Project Settings -> Plugins -> CAS.AI Config -> Autoload Interstitial Ads
.
Ad events
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: loading, opening, closing, and so on. Listen for these events by registering a delegate for the appropriate event, as shown below.
// Called when ad ready to shown.
UCASMobileAds::OnInterstitialAdLoaded.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Interstitial loaded"));
});
// Called when ad failed to load with error.
UCASMobileAds::OnInterstitialAdLoadFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("Interstitial failed to load: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the ad shown.
UCASMobileAds::OnInterstitialAdDisplayed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Interstitial displayed"));
});
// Called when the ad is failed to display.
UCASMobileAds::OnInterstitialAdShowFailed.AddLambda([=](ECASError Error){
UE_LOG(LogTemp, Log, TEXT("Interstitial failed to show: %s"),
UCASMobileAds::GetAdsErrorMessage(Error));
});
// Called when the user clicks on the Ad.
UCASMobileAds::OnInterstitialAdClicked.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Interstitial clicked"));
});
// Called when the ad is closed.
UCASMobileAds::OnInterstitialAdDismissed.AddLambda([=](){
UE_LOG(LogTemp, Log, TEXT("Interstitial dismissed"));
});
[!NOTE]
Ad events in Blueprints are registered in the Load and Show nodes. Each new Load/Show Ad node cancels previous node events.
Show the Ad
To display the ad, call the following method:
UCASMobileAds::ShowInterstitialAd();
Autoshow mode
Use the AutoshowInterstitialAd
method to automatically show the loaded ad when the user returns to the app.
UCASMobileAds::AutoshowInterstitialAd();
Use the DisableAutoshowInterstitialAd
method to disable automatically show the ad.
UCASMobileAds::DisableAutoshowInterstitialAd();
Release ad resource
Destroys the ad content and releases any associated resources when the ad is no longer needed to clean up resources and prevent memory leaks.
UCASMobileAds::DestroyInterstitialAd();
Call LoadInterstitialAd
to load new ad and restore autoload mode if used.
Ad Availability
You can ask for the ad availability directly by calling the following function:
bool AdLoaded = UCASMobileAds::IsInterstitialAdReady();
[!IMPORTANT]
We don’t recommend waiting forIsInterstitialAdReady
to change each frame. This method call the native SDK and can affect the performance of your game.
Subscribe to theOnInterstitialAdLoaded
event instead.
Minimum interval between impressions
You can limit the posting of an interstitial ad to a period of time in seconds after the ad is closed, during which display attempts will fail.
That the interval starts only after the Interstitial Ad closes OnInterstitialAdDismissed
.
During interval after ad closed, display attempts will fire event OnInterstitialAdShowFailed
with ECASError::IntervalNotYetPassed
.
Change the interstitial ad impression interval using the following method:
UCASMobileAds::SetInterstitialAdMinimumInterval(Interval);
If you need to wait for a period of time after the start of the game or after showing a Rewarded Ad until next Interstitial Ad impression then please call the following method:
UCASMobileAds::RestartInterstitialAdInterval();
[!NOTE]
We recommend define the interstitial ad impression interval once before mediation manager is initialized to be able to override the value remotely via the web interface.
Muted Ads Sounds
Sounds in Interstitial and Rewarded ads mute state. Disabled by default.
UCASMobileAds::SetAdsMuted(Mute);
Some best practices
- Consider whether interstitial ads are the right type of ad for your app.
Interstitial ads work best in apps with natural transition points. The conclusion of a task within an app, such as sharing an image or completing a game level, creates such a point. Because the user is expecting a break in the action, it's easy to present an interstitial ad without disrupting their experience. Make sure you consider at which points in your app's workflow you'll display interstitial ads and how the user is likely to respond. - Remember to pause the action when displaying an interstitial ad.
There are a number of different types of interstitial ads: text, image, video, and more. It's important to make sure that when your app displays an interstitial ad, it also suspends its use of some resources to allow the ad to take advantage of them. For example, when you make the call to display an interstitial ad, be sure to pause any audio output being produced by your app. You can resume playing sounds in theOnInterstitialAdClosed
event handler, which will be invoked when the user has finished interacting with the ad. In addition, consider temporarily halting any intense computation tasks (such as a game loop) while the ad is being displayed. This will make sure the user doesn't experience slow or unresponsive graphics or stuttered video. - Don't flood the user with ads.
While increasing the frequency of interstitial ads in your app might seem like a great way to increase revenue, it can also degrade the user experience and lower clickthrough rates. Make sure that users aren't so frequently interrupted that they're no longer able to enjoy the use of your app.
🔗 Done! What’s Next?
- Try another ad format:
- Read more about Impression level data.