Adaptive sticky banner

An adaptive sticky banner is a small, automatically updated ad placed at the bottom or top of the app screen. It doesn't overlap the main content and is often used in gaming apps.

The adaptive sticky banner delivers maximum performance by optimizing the ad size for each device. With this ad type, developers can set the maximum allowable ad width, and the system determines the optimal ad size automatically.

Appearance

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

Prerequisite

  1. Follow the Yandex Mobile Ads Compose Multiplatform plugin integration steps described under Quick start.
  2. Make sure that you have the latest version of the Yandex Mobile Ads Compose Multiplatform plugin. If you're using mediation, update to the most recent single build version.

Implementation

Key steps to integrate an adaptive sticky banner:

  • Add a Banner composable and pass BannerAdSize.Sticky with the container width.
  • Subscribe to lifecycle events using BannerEvents.

Features of adaptive sticky banner integration

  1. Create a state using rememberBannerAdState() with the size set to BannerAdSize.Sticky (container width in dp). Pass BannerEvents if needed.
  2. Trigger the ad load by calling loadAd(AdRequest) — typically from LaunchedEffect once the slot ID and width are ready.
  3. Pass the state to the Banner via the state parameter.

Sample layout:

@Composable
fun StickyBannerSlot(adRequest: AdRequest, width: Dp) {
    val bannerState = rememberBannerAdState(
        adSize = BannerAdSize.Sticky(width),
        events = BannerEvents(
            onAdLoaded = { adInfo -> /* ad loaded */ },
            onAdFailedToLoad = { error -> /* handle error */ },
            onAdClicked = { /* ad clicked */ },
            onImpression = { data -> /* impression tracked */ },
        ),
    )

    LaunchedEffect(adRequest) {
        bannerState.loadAd(adRequest)
    }

    Banner(
        state = bannerState,
        modifier = Modifier.fillMaxWidth(),
    )
}

You'll need an adUnitId to load ads. During integration, you can use the test ID demo-banner-yandex, but make sure to replace it with a production ID before release. Customize your request parameters through AdRequest (such as targeting, parameters, or preferredTheme), as extra context helps the system select more relevant ads. For more details, see Ad targeting.

Set the width based on the available space. We recommend using the full width of the parent container or screen, while factoring in padding and safe areas. The ad height is adjusted automatically.

Once loaded, the ad will display automatically.

Features of adaptive sticky banner integration

  1. If the onAdFailedToLoad callback reports an error, don't attempt to request a new ad immediately. If you can't avoid reloading, limit the number of attempts. This helps prevent endless failed requests and connection issues under poor network conditions.

  2. Adaptive sticky banners work best when they span the full available width. This is usually the width of the device screen. Don't forget to factor in your app's padding and safe areas.

  3. The size of the sticky banner remains consistent on the same device.

  4. The banner height is at least 50 dp and maximum 15% of the screen height.

Testing adaptive sticky banner integration

Using demo ad units for ad testing

Use test ads to check your adaptive sticky banner 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-banner-yandex.

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.

For the list of all available demo ad placement IDs, see Demo ad units for testing.

Testing ad integration

You can check if your adaptive sticky banners 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, a tool for debugging Android apps.

adb logcat -v brief '*:S YandexAds'

If the integration is successful, the following message is returned:

adb logcat -v brief '*:S YandexAds'
mobileads$ adb logcat -v brief '*:S YandexAds'
I/YandexAds(13719): [Integration] Ad type banner was integrated successfully

If there are any banner integration issues, you'll get a detailed issue report and troubleshooting recommendations.

Using demo ad units for ad testing

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-banner-yandex.

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.

For the list of all available demo ad placement IDs, see Demo ad units for testing.

Testing ad integration

You can test your ad integration using the native Console tool.

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

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.

Additional resources