Mediate Google AdMob

Instructions for passing user’s ad preference to AdMob

Publishers must work with Google for GDPR compliance by collecting consents on their own. To faciliate the process, the AdMob adapters (Android: 15.0.0.x / iOS: 7.30.0.x) will forward the user’s npa preference to Google. Publishers must make sure to complete the remaining steps below in their app:


  1. In your implementation, before you initialize the MoPub SDK, create a Bundle, and pass in the following value if the user does not consent to receive personalized ads:
      Bundle extras = new Bundle();
      extras.putString("npa", "1");
  2. In your SdkConfiguration object, pass that Bundle to the applicable AdMob adapters (all if the user does not consent to receive personalized ads for any ad format):
      SdkConfiguration sdkConfiguration = new SdkConfiguration.Builder(adUnitId)
         .withMediationSettings(new GooglePlayServicesBanner.GooglePlayServicesMediationSettings(extras),
                                new GooglePlayServicesInterstitial.GooglePlayServicesMediationSettings(extras),
                                new GooglePlayServicesRewardedVideo.GooglePlayServicesMediationSettings(extras),
                                new GooglePlayServicesNative.GooglePlayServicesMediationSettings(extras))


  1. In your implementation, before you initialize the MoPub SDK, create an instance of MPGoogleGlobalMediationSettings, and pass in the following value if the user does not consent to receive personalized ads:
     MPGoogleGlobalMediationSettings *mediationSettings = [[MPGoogleGlobalMediationSettings alloc] init];
     mediationSettings.npa = @"1";
  2. In your MPMoPubConfiguration object, pass in your instance of MPGoogleGlobalMediationSettings, and initialize with MPMoPubConfiguration:

     MPMoPubConfiguration *sdkConfig = [[MPMoPubConfiguration alloc] initWithAdUnitIdForAppInitialization: @"AD_UNIT_ID"];
     sdkConfig.globalMediationSettings = [[NSArray alloc] initWithObjects:mediationSettings, nil];
      [[MoPub sharedInstance] initializeSdkWithConfiguration:sdkConfig completion:^{
         NSLog(@"SDK initialization complete");


  • In your implementation, when you initialize the MoPub SDK, create an instance of MediationSetting, and pass in the following value if the user does not consent to receive personalized ads:

        MoPub.InitializeSdk(new MoPubBase.SdkConfiguration {
          AdUnitId = anyAdUnitId,
          MediationSettings = new[] {new MoPub.MediationSetting.AdMob {
              {"npa", "1"}

For additional context, please visit the AdMob articles (Android / iOS) on forwarding consent to the Mobile Ads SDK.

Download and Integration

To download the AdMob adapters, navigate to the Mediation Integration Tool. You will also need to download the Mobile Ads SDK, which can be found below.

For the latest download and integration instructions, ensure that you have consulted Google’s tutorials before you integrate the SDK and adapters.

iOS Download
Android Download
  • AdMob App ID

    • Android

      Publishers must add their AdMob App ID to the app’s AndroidManifest as a child of the <application></application> tag. This is a required step as of v17.0.0 of the Mobile Ads SDK. Failure to do so results in a crash. More information can be found on this page.

      <meta-data android:name=""

Set up AdMob Rewarded Video Demand

  • Navigate to the Networks section of your MoPub UI, select the “Add A Network”.
  • Select AdMob as the network.
  • Paste the AdMob ad unit ID to the “Ad Unit ID” field.

To access AdMob network reports for these formats, make sure to enter the network ids in the Google networks sections as shown below.

  1. Once you enable reporting as below for AdMob:

    AdMob Network Page

  2. Configure Admob ad unit IDs against the native MoPub ad unit IDs of your app as below:

    AdMob Network with AdMob IDs

Mediate AdMob Native Ad Demand

AdChoices Options

Google provides the option to select any of the four corners of the ad to render the AdChoices icon. To set a preferred AdChoices icon position for your app, follow the steps below. Ensure to set the preferred position before the ad request. The icon will be rendered in the topright corner by default if no custom position is set.


Call setAdChoicesPosition: from MPGoogleAdMobNativeCustomEvent with your preferred GADAdChoicesPosition position:

[MPGoogleAdMobNativeCustomEvent setAdChoicesPosition:GADAdChoicesPositionBottomRightCorner];


Pass the preferred position to a HashMap, then pass the HashMap in the setLocalExtras() call:

HashMap<String, Object> extras = new HashMap<>();

extras.put(GooglePlayServicesNative.KEY_EXTRA_AD_CHOICES_PLACEMENT, NativeAdOptions.ADCHOICES_TOP_LEFT);


(Optional) Additional assets

Google also supports the following additional assets that you can access using the below API:

  • Star Rating (app-install ads only)
    • Textview showing the star rating on 5.
  • Price (app-install ads only)
    • Textview showing price of the app.
  • Store (app-install ads only)
    • Textview app store name.
  • Advertiser (content ads only)
    • Textview showing the name of the advertiser.


static NSString *const kGADMAdvertiserKey = @"advertiser";
static NSString *const kGADMPriceKey = @"price";
static NSString *const kGADMStoreKey = @"store";

- (void)layoutCustomAssetsWithProperties:(NSDictionary *)customProperties {

    _priceLabel.text = [NSString stringWithFormat:@"%@", customProperties[@"price"]];
    _storeLabel.text = [NSString stringWithFormat:@"%@", customProperties[@"store"]];


ViewBinder mViewBinder = new ViewBinder.Builder(R.layout.native_ad_item)
        // bind to the other required assets here

Best Practices

MoPub Manual Integration

When using MoPub’s manual integration via AdapterHelper, it’s important to avoid using a recycled view that once displayed an ad from AdMob to display one from another network, and vice versa. The following code snippet shows how to render and show ads when manually integrating:

if (nativeAd.getMoPubAdRenderer() instanceof GooglePlayServicesAdRenderer) {

   // When creating an AdMob ad using AdapterHelper's
   // getAdView(convertView, parent, nativeAd, viewBinder), do not pass a view used to
   // display an ad from another network as convertView instead let the AdapterHelper
   // create a new one. Views used to show another AdMob ad can be reused.

} else {
   // Create/show ads from other networks.


AdMob renders the AdChoices icon in one of the four corners of the native ad view by default. Some layout designs can cause this icon to appear to be outside the ad’s content area. The following are some examples of the view hierarchies that might cause the AdChoices icon to be rendered on top of margins.

  • Layouts with empty views used as padding/margins:


  • Layout with margin on the child view (containing assets) relative to the outermost view.


  • Layouts with a margin on the outermost view.


Note: The Google Mobile Ads SDK considers the bounds of the top level view of the layout used to create the MoPub ViewHolder to define the bounds of the native ad’s presentation, and will place the AdChoices icon in one of the corners of those bounds.

The Google Mobile Ads SDK supports a different setting to allow publishers to specify the location of the AdChoices placement, and it addresses the layouts with margins noted above. However, your account must be enabled by AdMob for this feature. If you are affected by this margin issue and placing AdChoices in one of the four corners of the native ad view is not sufficient, please contact your account manager to request this feature. Once your account is whitelisted to use the customized Ad Choices placement, follow the below steps.


  • Modify your ad view layout by wrapping the MoPub privacy information icon with a FrameLayout with the ID “native_ad_choices_icon_container”. For example, if your privacy icon layout looks like this:

    <ImageView android:id="@+id/native_ad_daa_icon_image"
                android:padding="10dp" />

    You should modify it to look like like this:

    <FrameLayout android:id="@+id/native_ad_choices_icon_container"
                android:padding="10dp" >
       <ImageView android:id="@+id/native_ad_daa_icon_image"
                  android:layout_height="match_parent" />
  • Add the ID of the FrameLayout as an extra to the ViewBinder that would be provided to the GooglePlayServicesAdRenderer using the key GooglePlayServicesAdRenderer.VIEW_BINDER_KEY_AD_CHOICES_ICON_CONTAINER.

    mViewBinder = new ViewBinder.Builder(R.layout.native_ad_item)
      // bind to the other required assets here


No additional code is required. The Google adapter will place its AdChoices icon in the same spot where you placed the MoPub privacy icon.

Known Issues

  • Android - the AdChoices icon not visible when using CardView as the view passed to MoPub.

Test Ad

While testing your SDK integrations and network setups, it is recommended that you leverage test ad placements. To set up test mode, please reference Google’s test ad article for Android and iOS for instructions.

Last updated November 06, 2018

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2018 MoPub Inc.