---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.ru/doc/en/ad-monetization/dev/compose-multiplatform/interstitial.md
  - https://boost.yandex.ru/doc/ru/ad-monetization/dev/compose-multiplatform/interstitial.md
  - href: en/ad-monetization/dev/compose-multiplatform/interstitial.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.ru/doc/en/llms.txt

# Interstitial ads

<!-- source: en/ad-monetization/dev/_includes/interstitial.md -->
Interstitial advertising is a full-screen ad format embedded within the app content during natural pauses, such as transitioning between game levels or completing a target action.
<!-- endsource: en/ad-monetization/dev/_includes/interstitial.md -->

When an app displays an interstitial ad, the user can either click through to the advertiser's site or close the ad and return to the app.

During interstitial ad impressions, the user's attention is fully focused on the ad, which results in a higher cost for such impressions.

{% cut "Appearance" %}

<img src="https://yastatic.net/s3/doc-binary/src/docs/support/mobile-ads/en/monetization/_images/interstitial-en-ex.png" width="200">

{% endcut %}

This guide shows you how to integrate interstitial ads into a Compose Multiplatform app.
Besides code samples and instructions, it also contains format-specific recommendations and links to additional resources.

## Prerequisite {#pre}

<!-- source: en/ad-monetization/dev/_includes/pre-compose-multiplatform.md -->
1. Follow the Yandex Mobile Ads Compose Multiplatform plugin integration steps described under [Quick start](https://boost.yandex.ru/doc/en/ad-monetization/dev/compose-multiplatform/quick-start.md).
2. Make sure that you have the [latest version of the Yandex Mobile Ads Compose Multiplatform plugin](https://boost.yandex.ru/doc/en/ad-monetization/dev/platforms.md). If you're using mediation, update to the most recent [single build version](https://boost.yandex.ru/doc/en/ad-monetization/dev/platforms.md).
<!-- endsource: en/ad-monetization/dev/_includes/pre-compose-multiplatform.md -->

## Implementation {#implement}

Key steps for integrating interstitial ads:

1. Create an ad loader using `rememberInterstitialAdLoader()`.
2. Load the ad using the `loadAd()` suspend function.
3. If needed, attach a `InterstitialAdEventListener` to the loaded ad before calling `show()`.
4. Serve the ad using the `show()` method.

## Features of interstitial ad integration {#features}

If loading fails due to an exception or an error on your side, don't trigger a new request right away. If you can't avoid reloading, limit the number of attempts. This helps prevent endless failed requests and connection issues under poor network conditions.

## Loading ads

Create an ad loader using `rememberInterstitialAdLoader()`, then call `loadAd` with an `AdRequest` containing the `adUnitId` as specified in the Boost interface.

Customize the request parameters using `AdRequest` (such as `targeting`, `parameters`, and `preferredTheme`). Adding more context to your request greatly improves ad relevance. For more details, see [Ad targeting](https://boost.yandex.ru/doc/en/ad-monetization/dev/compose-multiplatform/target.md).

Example of loading an interstitial ad:

```kotlin
@Composable
fun InterstitialBlock(adUnitId: String) {
    val loader = rememberInterstitialAdLoader()
    val scope = rememberCoroutineScope()
    var interstitialAd by remember { mutableStateOf<InterstitialAd?>(null) }
    var isLoading by remember { mutableStateOf(false) }

    Button(
        onClick = {
            isLoading = true
            scope.launch {
                try {
                    interstitialAd = loader.loadAd(AdRequest(adUnitId = adUnitId))
                } catch (e: AdLoadException) {
                    // Load error: e.error (AdRequestError). Unlimited retries are not recommended.
                }
                isLoading = false
            }
        },
        enabled = !isLoading,
    ) {
        Text(if (isLoading) "Loading..." else "Load interstitial ad")
    }

    Button(
        onClick = {
            interstitialAd?.show()
            interstitialAd = null
        },
        enabled = interstitialAd != null,
    ) {
        Text("Show interstitial ad")
    }
}
```

For debugging, you can use `'demo-interstitial-yandex'` as the `adUnitId`.

## Displaying ads

Show interstitial ads during natural pauses in the app's flow — for example, between game levels or after a target action (such as when a file download is complete).

To track lifecycle events, set an `InterstitialAdEventListener` on the `InterstitialAd` instance before calling `show()`.

```kotlin
val ad = interstitialAd ?: return
ad.setAdEventListener(
    object : InterstitialAdEventListener {
        override fun onAdShown() {
            // Called when an ad is shown.
        }

        override fun onAdFailedToShow(adError: AdError) {
            // Called when an ad failed to show. Clear the reference and preload the next ad if needed.
        }

        override fun onAdDismissed() {
            // Called when ad is dismissed. Preload the next interstitial here if appropriate.
        }

        override fun onAdClicked() {
            // Called when a click is recorded for an ad.
        }

        override fun onAdImpression(impressionData: ImpressionData?) {
            // Called when an impression is recorded for an ad.
        }
    },
)
ad.show()
```

## Releasing resources

Once `onAdDismissed` or `onAdFailedToShow` fire, release the references to the ad object and start loading the next creative if needed. Don't store strong references to ads that have already been served.

## Testing interstitial ad integration {#test}

{% list tabs %}

- Android

   <!-- source: en/ad-monetization/dev/_includes/test-android-interstitial.md -->
   ### Using demo ad units for ad testing {#demo-blocks}

   Use test ads to check your interstitial ad integration and the app itself. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.

   Demo adUnitId: `demo-interstitial-yandex`.

   {% note warning %}

   Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Boost interface.

   {% endnote %}

   For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://boost.yandex.ru/doc/en/ad-monetization/dev/android/demo-blocks.md).

   ### Testing ad integration {#test-int}

   You can check if your interstitial ads are integrated correctly using the SDK's built-in analyzer. A detailed report with the test results will appear in the log.

   To view the report, search for the keyword “YandexAds” in [Logcat](https://developer.android.com/studio/command-line/logcat), a tool for debugging Android apps.
   ```bash
   adb logcat -v brief '*:S YandexAds'
   ```

   If the integration is successful, the following message is returned:
   ```bash
   adb logcat -v brief '*:S YandexAds'
   mobileads$ adb logcat -v brief '*:S YandexAds'
   I/YandexAds(13719): [Integration] Ad type interstitial was integrated successfully
   ```

   If there are any interstitial ad integration issues, you'll get a detailed issue report and troubleshooting recommendations.
   <!-- endsource: en/ad-monetization/dev/_includes/test-android-interstitial.md -->

- iOS

   ### Using demo ad units for ad testing

   <!-- source: en/ad-monetization/dev/_includes/test-ios-interstitial.md -->
   Use test ads to check your ad integration and the app itself. To make sure that test ads are returned for each ad request, you can use a special demo ad placement ID.

   Demo adUnitId: `demo-interstitial-yandex`.

   {% note warning %}

   Before publishing your app in the store, make sure to replace the demo placement ID with the real ID you obtained in the Boost interface.

   {% endnote %}

   For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://boost.yandex.ru/doc/en/ad-monetization/dev/ios/demo-blocks.md).
   <!-- endsource: en/ad-monetization/dev/_includes/test-ios-interstitial.md -->

   ### Testing ad integration

   <!-- source: en/ad-monetization/dev/_includes/test-integration-ios.md -->
   You can test your ad integration using the native Console tool.

   To view detailed logs, call the `YandexAds` class's `enableLogging` method.

   ```swift
   YandexAds.enableLogging()
   ```

   To view SDK logs, go to the Console tool and set `Subsystem = com.mobile.ads.ads.sdk`. You can filter logs by category or error level.

   If you're having problems integrating ads, you'll get a detailed report on the issues and recommendations for how to fix them.

   <img src= "https://yastatic.net/s3/doc-binary/src/dev/mobile-ads/common/integration-ios-2.png">
   <!-- endsource: en/ad-monetization/dev/_includes/test-integration-ios.md -->

{% endlist %}

## Tips

### Ad preloading

<!-- source: en/ad-monetization/dev/_includes/preload.md -->
Loading an ad may take several seconds, depending on the number of ad networks connected in Mobile Mediation and the user's internet speed. We recommend preloading ads before displaying them.
<!-- endsource: en/ad-monetization/dev/_includes/preload.md -->

Call the `loadAd` method in advance to instantly show the ad when it's needed.

If you want to start loading the next ad immediately after the current one is shown, link this process to the `onAdDismissed` event.

<!-- source: en/ad-monetization/dev/_includes/cash-ads.md -->
If you cache ads on too many screens that are unlikely to be shown, your ad effectiveness could drop. For example, if users complete 2-3 game levels per session, you shouldn't cache ads for 6-7 screens. Your ad viewability could decrease otherwise, and the advertising system might deprioritize your app.

To ensure caching benefits your app, monitor the “Show rate” or “View rate” metrics in the Boost interface. If it's under 20%, you should probably revise your caching algorithm. The higher the percentage of impressions, the better.
<!-- endsource: en/ad-monetization/dev/_includes/cash-ads.md -->

## Additional resources {#resources}

* <!-- source: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
  Link to [GitHub](https://github.com/yandexmobile/yandex-ads-multiplatform).
  <!-- endsource: en/ad-monetization/dev/_includes/github-pubdev-links.md -->
