Anchored adaptive banners

Adaptive banners are the next generation of responsive ads, maximizing performance by optimizing ad size for each device. Improving on smart banners, which only supported fixed heights, adaptive banners let you specify the ad-width and use this to determine the optimal ad size.

To pick the best ad size, adaptive banners use fixed aspect ratios instead of fixed heights. This results in banner ads that occupy a more consistent portion of the screen across devices and provide opportunities for improved performance.

When working with adaptive banners, note that they will always return a constant size for a given device and width. Once you've tested your layout on a given device, you can be sure that the ad size will not change. However, the size of the banner creative may change across different devices. Consequently, it is recommended to ensure your layout can accommodate variances in ad height. In rare cases, the full adaptive size may not be filled and a standard size creative will be centered in this slot instead.

When to use adaptive banners

Adaptive banners are designed to be a drop-in replacement for the industry standard 320x50 banner size, as well as the smart banner format they supersede.

These banner sizes are commonly used as anchored banners, which are usually locked to the top or bottom of the screen. For such anchored banners, the aspect ratio when using adaptive banners will be similar to that of a standard 320x50 ad, as can be seen in these screenshots:


320x50 banner

Smart banner

Adaptive banner

An adaptive banner makes better use of the available screen size. Additionally, compared to a smart banner, an adaptive banner is a better choice because:

  • It uses a provided width rather than full screen width, enabling you to account for safe areas.

  • It selects an optimal height for the specific device, rather than having a constant height across different sized devices, mitigating the effects of device fragmentation.

Implementation notes

When implementing adaptive banners in your app, keep the following points in mind:

  • You must know the width of the view that the ad will be placed in, and this should take into account the device width and any safe areas that are applicable.

  • Ensure that your ad view background is opaque to be compliant with AdMob policies when smaller ad sizes serve that do not fill the ad slot.

  • Ensure you are using the latest version of the Google Mobile Ads C++ SDK. For mediation, use the latest version of each mediation adapter.

  • The adaptive banner sizes are designed to work best when using the full available width. In most cases, this will be the full width of the screen of the device in use. Be sure to take into account applicable safe areas.

  • The Google Mobile Ads C++ SDK returns an optimized ad height for the given width in a firebase::gma::AdSize.

  • There are three methods to get an ad size for adaptive banners—one for landscape, one for portrait, and one for the current orientation at the time of execution.

  • The size returned for a given width on a given device will always be the same, hence once you've tested your layout on a given device, you can be sure that the ad size will not change.

  • Anchored banner height is never larger than 15% of the device's height and never smaller than 50 points.

Quick start

Follow the steps below to implement a simple adaptive anchor banner.

  1. Get an adaptive banner ad size. The size you get will be used to request your adaptive banner. To get the adaptive ad size, make sure that you:

    1. Get the width of the device in use, or set your own width if you don't want to use the full width of the screen.

    2. Use the appropriate static methods on the AdSize class, such as GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width) to get an adaptive AdSize object for the chosen orientation.

    3. Invoke Initialize() on the AdView with the adaptive AdSize you've created.

      A full example is included below.

  2. Create an AdRequest object and load your banner using the loadAd() method on your prepared ad view, just like you would with a normal banner request.

Sample code

Here's an example of an AdView that will load an adaptive banner:

// Determine view width in pixels based on your app's current width on the
// device's screen. This process will vary depending on which windowing toolkit
// you're using.

firebase::gma::AdSize adaptive_ad_size =
      AdSize::GetCurrentOrientationAnchoredAdaptiveBannerAdSize(view_width);

// my_ad_parent is a reference to an iOS UIView or an Android Activity.
// This is the parent UIView or Activity of the banner view.
firebase::gma::AdParent ad_parent =
  static_cast<firebase::gma::AdParent>(my_ad_parent);
firebase::Future<void> result =
  ad_view->Initialize(ad_parent, kBannerAdUnit, adaptive_ad_size);

Here, the function GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width) is used to get the size for a banner in an anchored position for the current interface orientation. For pre-loading an anchored banner in a given orientation, use the relevant function from GetPortraitAnchoredAdaptiveBannerAdSize(uint32_t width) and GetLandscapeAnchoredAdaptiveBannerAdSize(uint32_t width).