---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/compose-multiplatform/interstitial.md
  - https://ads.yandex.com/helpcenter/ru/dev/compose-multiplatform/interstitial.md
  - https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/interstitial.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/en/llms.txt

# Interstitial advertising

<!-- source: en/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/dev/_includes/interstitial.md -->

When the app renders an interstitial ad, the user has two options: click the ad and proceed to the advertiser site or close the ad and go back to the app.

In interstitial ads, user attention is fully focused on the ads, which is why the impression cost is higher.

{% 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 how to integrate interstitial ads into Compose Multiplatform apps.
In addition to code samples and instructions, it contains format-specific recommendations and links to additional resources.

## Prerequisite {#pre}

<!-- source: en/dev/_includes/pre-compose-multiplatform.md -->
1. Follow the process in [Quick start](https://ads.yandex.com/helpcenter/en/dev/compose-multiplatform/quick-start.md) to integrate the Yandex Mobile Ads Compose Multiplatform Plugin.
2. Make sure you're running the latest [Yandex Mobile Ads Compose Multiplatform Plugin](https://ads.yandex.com/helpcenter/en/dev/platforms.md) version. If you're using mediation, make sure you're running the latest version of the [unified build](https://ads.yandex.com/helpcenter/en/dev/platforms.md).
<!-- endsource: en/dev/_includes/pre-compose-multiplatform.md -->

## Implementation {#implement}

Key steps for integrating interstitial ads:

1. Create the ad loader with `rememberInterstitialAdLoader()`.
2. Load the ad through the suspend function `loadAd()`.
3. Optionally set `InterstitialAdEventListener` on the loaded ad before calling `show()`.
4. Show the ad using `show()`.

## Features of interstitial ads integration {#features}

If loading throws or reports a failure through your error handling, don't try to load a new ad again immediately. If there's no other option, limit the number of ad load retries. That will help avoid constant unsuccessful requests and connection issues when limitations arise.

## Loading ads

Create the loader with `rememberInterstitialAdLoader()`, then call `loadAd` with an `AdRequest` that contains your `adUnitId` from the Yandex Advertising Network interface. On load failure, `loadAd` throws `AdLoadException` from `com.yandex.mobile.ads.kmp.common`.

You can expand the request through `AdRequest` (`targeting`, `parameters`, `preferredTheme`, and so on). Delivering additional contextual data in the request can significantly improve your ad quality. Read more in the [Ad Targeting](https://ads.yandex.com/helpcenter/en/dev/compose-multiplatform/target.md) section.

The following example shows how to load 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). Unbounded retries are discouraged.
                }
                isLoading = false
            }
        },
        enabled = !isLoading,
    ) {
        Text(if (isLoading) "Loading..." else "Load interstitial")
    }

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

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

## Ad rendering

Interstitial ads should be displayed during natural pauses in the app's operation — for example, between game levels or after a conversion (when a file has finished downloading).

To track the interstitial ad lifecycle, set `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

After `onAdDismissed` or `onAdFailedToShow`, drop references to the ad object and, if needed, start loading the next creative. Do not keep strong references to ads that have already been shown.

## Testing interstitial ad integration {#test}

{% list tabs %}

- Android

  <!-- source: en/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 Yandex Advertising Network interface.

  {% endnote %}

  For the list of all available demo ad placement IDs, see [Demo ad units for testing](https://ads.yandex.com/helpcenter/en/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/dev/_includes/test-android-interstitial.md -->

- iOS

  ### Using demo ad units for ad testing

  <!-- source: en/dev/_includes/test-ios-interstitial.md -->
  We recommend using test ads to test your ad integration and your app itself.

  To guarantee that test ads are returned for every ad request, we created a special demo ad placement ID. Use it to check your ad integration.

  Demo adUnitId: `demo-interstitial-yandex`.

  {% note warning %}

  Make sure that before placing the application in the store, you replaced the demo ad placement ID with a real one, obtained in the Yandex Advertising Network interface.

  {% endnote %}

  You can find the list of available demo ad placement IDs in the [Demo ad units for testing](https://ads.yandex.com/helpcenter/en/dev/ios/demo-blocks.md) section.
  <!-- endsource: en/dev/_includes/test-ios-interstitial.md -->

  ### Testing ad integration

  <!-- source: en/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 also filter logs by category and 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/dev/_includes/test-integration-ios.md -->

{% endlist %}

## Tips

### Ad preloading

<!-- source: en/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/dev/_includes/preload.md -->

Call `loadAd` in advance to display the loaded ad at the right moment.

To start loading the next ad right after serving the current one, bind this process to the `onAdDismissed` event.

<!-- source: en/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 make sure you're finding a good balance for your app, track the "Share of impressions" or "Share of visible impressions" metric in the Yandex Advertising Network interface. If it's under 20%, you should probably revise your caching algorithm. The higher the percentage of impressions, the better.
<!-- endsource: en/dev/_includes/cash-ads.md -->

## Additional resources {#resources}

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