Mediation

This guide shows you how to integrate a mediation adapter with your current Android app and set up additional request parameters.

Prerequisites

Check which ad network adapter class loaded the ad

Here is some sample code that logs the ad network class name for a banner ad:

Java

public void onAdLoaded() {
  Log.d("Banner adapter class name: " + ad.getResponseInfo().getMediationAdapterClassName());
}

Kotlin

override fun onAdLoaded() {
  Log.d("Banner adapter class name:" + ad.responseInfo.mediationAdapterClassName)
}

Refer to the ResponseInfo documentation on getMediationAdapterClassName() for details about this method.

Initialize your ad object with an Activity instance

In the constructor for a new ad object (for example, AdManagerAdView), you must pass in an object of type Context. This Context is passed on to other ad networks when using mediation. Some ad networks require a more restrictive Context that is of type Activity and may not be able to serve ads without an Activity instance. Therefore, we recommend passing in an Activity instance when initializing ad objects to ensure a consistent experience with your mediated ad networks.

Rewarded ads mediation

We recommend that you override all default reward values by setting reward values in the Ad Manager UI. To do this, select the Override reward settings from third-party ad networks when using mediation box so that the reward is consistent across all networks. Some ad networks don't provide a reward value or type at all. By overriding the reward value, the reward is consistent no matter which ad network served the ad.

Refer to set up and traffic rewarded ads for apps for more information.

Native ads mediation

The following are some best practices to consider when implementing native mediation.

Native ad presentation policy
Each ad network has its own policies. When using mediation, it's important to remember that your app still needs to abide by the policies of the mediated network that provided the ad.
Use loadAd() instead of loadAds()
The loadAds() method currently serves only Google ads. For mediated ads, use loadAd() instead.