Integrating MoPub with Mediation

This guide is for publishers who want to use the Google Mobile Ads SDK to load and display ads from MoPub via mediation. It covers how to add MoPub to an ad unit's mediation configuration, how to set up Automatic data collection, and how to integrate the MoPub SDK and adapter into an iOS app.

Supported ad formats and features

The Ad Manager mediation adapter for MoPub has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Rewarded Video (new APIs)
Native Ad - Custom Rendering
Features
Smart banners
Automatic data collection
Native Video

Requirements

  • iOS deployment target of 8.0 or higher
  • Latest Google Mobile Ads SDK

Step 1: Set up MoPub

First, sign up and log in to your MoPub UI. Navigate to the Apps page and click the Add a New App button.

MoPub new app

Select iOS as the Platform for your app, enter the App name and iTunes URL of your app. Then select a primary and secondary category of your app from the provided list.

MoPub app

MoPub requires you to create your first ad unit before you can finish adding your app.

For additional instructions on creating an ad unit, select the tab corresponding to your preferred ad format.

Choose Tablet as the Device type. Choose a banner format that matches the ad size you're requesting in your app. Enter a Name for your ad unit.

The refresh rate is handled by the Google Mobile Ads SDK according to your refresh rate setting in the Ad Manager UI. So, we recommend using a high value for the Refresh Interval here (e.g. 1000 seconds).

Banner

Interstitial

Choose Tablet as the Device type. Choose Tablet Full Screen as the Format. Enter a Name for your ad unit. Choose the type of Layout to present the ad in.

Interstitial

Native

Choose Tablet as the Device type. Choose Native (Custom layout) as the Format. Enter a Name for your ad unit.

Interstitial

Click Save and View Code Integration to get your Ad Unit ID.

MoPub ad unit id

In addition to the Ad Unit ID, you'll also need to obtain your MoPub API Key and Inventory Report ID to set up your Ad Manager ad unit ID. To find your API Key and Inventory Report ID, navigate to the Reports page and click View API Access Details.

MoPub reporting keys

MoPub Marketplace

To get ads from MoPub, your account must be approved for MoPub Marketplace. During your initial account setup, you will be prompted to go through the process for Marketplace approval. Part of this process includes entering your payment information.

MoPub marketplace

See the Marketplace setup guide for more details.

Step 2: Configure mediation settings for your Ad Manager ad unit

Sign in to your Ad Manager account. Navigate to Delivery > Yield groups and click the New yield group button.

Enter a unique Name for your yield group, set the Status to Active, select your Ad Format, and set the Inventory type to Mobile App. Under the Targeting > Inventory section, select the Ad Unit ID to which you want to add mediation.

Next, click the Add yield partner button.

If you already have a Yield partner for MoPub, you can simply select it. Otherwise, select Create a new yield partner.

Select MoPub as the Ad network and enter a unique Name. Enable Mediation and turn on Automatic data collection, and enter the API Key and Inventory Report ID obtained in the previous section. You don't need to enter a Username and Password. Click Save when finished.

Once the Yield partner is selected, choose Mobile SDK mediation as the Integration type, iOS as the Platform, and Active as the Status. Enter the Ad Unit ID obtained in the previous section and a Default CPM value.

Click Save at the bottom of the page when done.

Using rewarded video ads

In the settings for your rewarded video ad unit, provide values for the reward amount and reward type. Then, to ensure you provide the same reward to the user no matter which ad network is served, check the Override reward settings from third-party ad networks when using mediation box.

Override reward

If you don't apply this setting, the MoPub adapter passes back the reward specified in the MoPub dashboard.

Step 3: Import the MoPub SDK and adapter

  • Add the following line to your project's Podfile:

    pod 'GoogleMobileAdsMediationMoPub'
    
  • From the command line run:

    pod install --repo-update

Manual integration

  • Download the latest version of the MoPub SDK and link the MoPubSDK source code in your project.
  • Download the latest version of the MoPub adapter and link MoPubAdapter.framework in your project.

Step 4: Additional code required

Initialize the MoPub SDK

Before loading ads, have your app initialize the MoPub SDK by calling initializeSdkWithConfiguration: with a valid MoPub Ad Unit ID you created in Step 1. This needs to be done only once, ideally at app launch.

#import "MoPub.h";
…

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  MPMoPubConfiguration *sdkConfig =
  [[MPMoPubConfiguration alloc] initWithAdUnitIdForAppInitialization:@"YOUR_MOPUB_AD_UNIT_ID"];

  [[MoPub sharedInstance] initializeSdkWithConfiguration:sdkConfig completion:nil];
  return YES;
}

@end

Step 5: Test your implementation

To get test ads from MoPub, you need a guaranteed or backfill line item. MoPub recommends adding the Demo line item to your ad unit to get test ads. The Demo line item is added to your MoPub account by default.

MoPub demo item

The Demo Line Item contains test creatives for native and banner ad units by default, but does not have a test creative for interstitial ad units. To add your own test creative for interstitial ads, you need to upload a simple image to the MoPub UI by navigating to the Demo Line Item and clicking the Add a New Creative button. Choose Tablet Full Screen format. Fill the form with the necessary details and click Save to add your test creative to the Demo Line Item.

MoPub demo item

That's it! You now have a working mediation integration with MoPub.

Optional steps

Under the Google EU User Consent Policy, you must ensure that certain disclosures are given to, and consents obtained from, users in the European Economic Area (EEA) regarding the use of device identifiers and personal data. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR). When seeking consent, you must identify each ad network in your mediation chain that may collect, receive, or use personal data and provide information about each network's use. Google currently is unable to pass the user's consent choice to such networks automatically.

To collect consent for MoPub, MoPub asks that you use its consent mechanism. See the MoPub GDPR Publisher Integration Guide for more information.

Using native ads

Network-specific parameters

The MoPub adapter supports an additional request parameter which can be passed to the adapter using the GADMoPubNetworkExtras class. This class includes the following property:

  • privacyIconSize - Set the size for the MoPub privacy icon in points. Values can range from 10 to 30 inclusive. The default size for the privacy icon is 20.

Here's a code example of how to set this parameter at ad request time:

Swift

let adRequest = DFPRequest()
let extras = GADMoPubNetworkExtras()
extras.privacyIconSize = 15
adRequest.registerAdNetworkExtras(extras)

Objective-C

DFPRequest *request = [DFPRequest request];
GADMoPubNetworkExtras *extras = [[GADMoPubNetworkExtras alloc] init];
extras.privacyIconSize = 15;
[adRequest registerAdNetworkExtras:extras];

Ad Rendering

The MoPub adapter returns its native ads as GADUnifiedNativeAd objects. It populates the following fields for a GADUnifiedNativeAd.

Field Populated by MoPub adapter
Headline
Image
Body
App icon
Call to action
Star rating
Store
Price

Impression and Click Tracking

MoPub and Google Mobile Ads SDKs track impressions in their own way, so there may be discrepancies.

Clicks are detected by the Google Mobile Ads SDK and are forwarded to MoPub SDK, so click reporting will be in sync.

Additional Resources

For more details on how to set up test ad units, consult MoPub's Testing pages.

MoPub iOS Mediation Adapter Changelog

Version 5.13.0.0

  • Verified compatibility with MoPub SDK 5.13.0.
  • Now requires Google Mobile Ads SDK version 7.60.0 or higher.
  • Now requires minimum iOS version of 10.0.

Built and tested with

  • Google Mobile Ads SDK version 7.60.0.
  • MoPub SDK version 5.13.0.

Version 5.12.1.0

  • Verified compatibility with MoPub SDK 5.12.1.

Built and tested with

  • Google Mobile Ads SDK version 7.58.0.
  • MoPub SDK version 5.12.1.

Version 5.12.0.1

  • Fixed a regression in 5.12.0.0 where banner ads did not load.

Built and tested with

  • Google Mobile Ads SDK version 7.58.0.
  • MoPub SDK version 5.12.0.

Version 5.12.0.0 (Deprecated)

  • Verified compatibility with MoPub SDK 5.12.0.
  • Now requires Google Mobile Ads SDK version 7.58.0 or higher.
  • Added support for flexible banner ad sizes.
  • Added a new extra to the GADMoPubNetworkExtras class:
    • minimumBannerSize - minimum ad size allowed for MoPub banner ads.

Built and tested with

  • Google Mobile Ads SDK version 7.58.0.
  • MoPub SDK version 5.12.0.

Version 5.11.0.0

  • Verified compatibility with MoPub SDK 5.11.0.

Built and tested with

  • Google Mobile Ads SDK version 7.56.0.
  • MoPub SDK version 5.11.0.

Version 5.10.0.1

  • Added standardized adapter error codes and messages.
  • Removed support for the i386 architecture.

Built and tested with

  • Google Mobile Ads SDK version 7.56.0.
  • MoPub SDK version 5.10.0.

Version 5.10.0.0

  • Verified compatibility with MoPub SDK 5.10.0.

Built and tested with

  • Google Mobile Ads SDK version 7.52.0.
  • MoPub SDK version 5.10.0.

Version 5.9.0.0

  • Verified compatibility with MoPub SDK 5.9.0.
  • Now requires minimum iOS version of 9.0.
  • Removed support for Native App Install ad requests. Apps must use the Unified Native Ads API to request native ads.
  • Now requires Google Mobile Ads SDK version 7.52.0 or higher.

Built and tested with

  • Google Mobile Ads SDK version 7.52.0.
  • MoPub SDK version 5.9.0.

Version 5.7.1.0

  • Verified compatibility with MoPub SDK 5.7.1.

Version 5.6.0.1

  • Updated adapter to use the new rewarded API.
  • Now requires Google Mobile Ads SDK version 7.42.2 or higher.

Version 5.6.0.0

  • Verified compatibility with MoPub SDK 5.6.0.
  • Interstitial requests will now fail if there is already a loaded MoPub ad for that publisher ID. MoPub can only load 1 ad per publisher ID at a time.

Version 5.5.0.0

  • Verifed compatibility with MoPub SDK 5.5.0.

Version 5.4.1.1

  • Added support for requesting MoPub Rewarded video ads via Google Mobile Ads mediation.

Version 5.4.1.0

  • Verifed compatibility with MoPub SDK 5.4.1.

Version 5.4.0.1

  • Added location forwading capability to the adapter.

Version 5.4.0.0

  • Verifed compatibility with MoPub SDK 5.4.0.

Version 5.3.0.2

  • Remove the check that prevents ad requests for native content ad.

Version 5.3.0.1

  • Initialize MoPub and reattempt ad requests manually in the adapters for use cases that do not do so in the app.

Version 5.3.0.0

  • Verifed compatibility with MoPub SDK 5.3.0.

Version 5.2.0.0

  • Verifed compatibility with MoPub SDK 5.2.0.

Version 5.1.0.0

  • Verfied compatibility with MoPub SDK 5.1.0.

Version 5.0.0.0

  • Verified compatibility with MoPub SDK 5.0.0.

Version 4.20.1.0

  • Fixed an issue causing duplicate symbol errors when the adapter was used with those of other networks.
  • Verified compatibility with MoPub SDK 4.20.1.

Version 4.20.0.0

  • The adapter now returns a media view for every native ad.
  • Verified compatibility with MoPub SDK 4.20.0.

Version 4.19.0.0

  • Verified compatibility with MoPub SDK 4.19.0.

Version 4.18.0.0

  • Verified compatibility with MoPub SDK 4.18.0.

Version 4.17.0.0

  • Updated the deployment target to iOS 8.
  • Updated the adapter to make it compatibe with MoPub SDK 4.17.0.

Version 4.16.0.0

  • The adapter now depends on mopub-ios-sdk/Core. MoPub SDK uses Integral Ad Science, Inc. (“IAS”) and Moat, Inc for reporting and viewability measurement. If you wish to use these libaries, they need to be added to your app separately. See Disabling Viewability Measurement for more details on how to add these libraries separately.
  • Verified compatibility with MoPub SDK 4.16.0.

Version 4.15.0.0

  • Verified compatibility with MoPub SDK 4.15.0.

Version 4.14.0.0

  • Verified compatibility with MoPub SDK 4.14.0.
  • Removed the support for armv7s architecture.
  • Fixed a bug where Native Ads failed to load MoPub privacy icon when MoPub SDK is linked using CocoaPods and having use_frameworks! in the Podfile for Swift projects.

Version 4.13.1.1

  • Fixed a bug where native ads failed to detect clicks when loaded from the same GADAdLoader instance.

Version 4.13.1.0

  • Verified compatibility with MoPub SDK 4.13.1.

Version 4.13.0.0

  • Verified compatibility with MoPub SDK 4.13.0.

Version 4.12.0.0

  • Verified compatibility with MoPub SDK 4.12.0.
  • Added support for accessing MoPub native demand on Google Mobile Ads mediation.
  • Added support to configure the privacy icon size for MoPub's native ads.
  • Updated banner and interstitial ad formats per Google Mobile Ads latest mediation APIs.
  • Adapter is now distributed as a framework.

Previous Versions

  • Support for MoPub banner and interstitial ads.