Integrating MoPub with Mediation

This guide is intended 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, and how to integrate the MoPub SDK and adapter into a Unity app.

Supported ad formats and features

The AdMob mediation adapter for MoPub has the following capabilities:

Formats
Banners
Interstitials
Rewarded Video
Features
Smart banners
Ad Network Optimization (ANO)

Requirements

  • Unity 4 or higher
  • To deploy on Andorid
    • Android SDK 4.1 (API level 16) or higher
    • Google Play services 9.6.1 or higher
  • To deploy on iOS
    • Xcode 6.0 or higher
    • iOS Deployment target of 7.0 or higher
    • Minimum required Google Mobile Ads SDK 7.14.0 or higher
  • A working Unity project configured with Google Mobile Ads SDK. See Get Started for details.

Step 1: Set up MoPub

First, sign up (if you haven't already) and log in to your MoPub UI. Navigate to the Apps page and click the Add a New App button.

MoPub new app

Select the Platform for which you would want to set up Unity Ads. If your app supports both platforms (Android and iOS), you need to add your apps separately for each platform.

Enter the Name of your app, Package name of your app, and 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 completing the registration of your app.

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

Banner

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 UI. So, we recommend using a high value for the Refresh Interval here (e.g. 1000 seconds).

Interstitial

Choose Tablet as the Device type. Choose Fullscreen Tablet as the Format. Enter a Name for your Ad Unit. Choose the type of Layout to present the ad in.

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

MoPub ad unit id

We will use this Ad Unit ID to set up your AdMob Ad Unit ID for mediation in the next section.

MoPub Marketplace

To get ads from MoPub, your account needs to 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 Marketplace setup for more details.

Step 2: Configure AdMob Ad Unit

You need to add MoPub to the mediation configuration for your Ad Unit. First sign into the AdMob UI.

If you're deploying your Unity app to both Android and iOS, you need two AdMob ad units, one for each platform.

Next, follow the instructions for either AdMob or AdMob Beta depending on which version of the AdMob UI you're using.

AdMob Android

Navigate to the Monetize tab and select your application from the list of All apps on the left-hand side. Click the link in the mediation column for the ad unit you want to mediate to MoPub.

MoPub mediation ad source

Click NEW AD NETWORK.

MoPub ad network new

Select MoPub from the list of available ad networks and enter the Ad Unit ID obtained in the previous section.

MoPub ad network

Click Continue at the bottom of the page to complete adding the network. Enter an eCPM value for MoPub and click Save.

AdMob iOS

Navigate to the Monetize tab and select your application from the list of All apps on the left-hand side. Click the link in the mediation column for the ad unit you want to mediate to MoPub.

MoPub mediation ad source

Click NEW AD NETWORK.

MoPub ad network new

Select MoPub from the list of available ad networks and enter the Ad Unit ID obtained in the previous section.

MoPub ad network

Click Continue at the bottom of the page to complete adding the network. Enter an eCPM value for MoPub and click Save.

AdMob Beta Android

Navigate to the Mediation tab. If you have an existing mediation group you'd like to modify, click the name of that mediation group to edit it, and skip ahead to Add MoPub as an ad source.

To create a new mediation group, select Create Mediation Group.

AdMob Beta mediation tab

Enter your ad format and platform, then click Continue.

Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units, which will open up the ad unit selection overlay.

New mediation group 2

Associate this mediation group with your existing AdMob ad unit. Then click Done.

Select ad unit

You should now see the ad units card populated with the ad units you selected.

Mediation group ad units

Add MoPub as an ad source

In the Ad Sources card, select Add Ad Network. Then select MoPub.

Then enter an eCPM value for MoPub and click Continue.

Next, enter the Ad Unit ID obtained in the previous section. Then click Done.

Configure MoPub ad unit

Finally, click Save.

AdMob Beta iOS

Navigate to the Mediation tab. If you have an existing mediation group you'd like to modify, click the name of that mediation group to edit it, and skip ahead to Add MoPub as an ad source.

To create a new mediation group, select Create Mediation Group.

AdMob Beta mediation tab

Enter your ad format and platform, then click Continue.

Give your mediation group a name, and select locations to target. Next, set the mediation group status to Enabled. Then click Add Ad Units, which will open up the ad unit selection overlay.

New mediation group 2

Associate this mediation group with your existing AdMob ad unit. Then click Done.

Select ad unit

You should now see the ad units card populated with the ad units you selected.

Mediation group ad units

Add MoPub as an ad source

In the Ad Sources card, select Add Ad Network. Then select MoPub.

Then enter an eCPM value for MoPub and click Continue.

Next, enter the Ad Unit ID obtained in the previous section. Then click Done.

Configure MoPub ad unit

Finally, click Save.

Step 3: Import the MoPub SDK and adapter

Android

  1. Download the latest versions of the following MoPub SDK modules
  2. Download the latest version of MoPub Volley (mopub-volley-a.b.c.aar) library required by MoPub SDK.
  3. Download the latest MoPub adapter (mopub-4.19.0.1.aar) from Bintray.
  4. Add all the .aar files to the Assets/Plugins/Android directory in your Unity project.

iOS

Download the latest MoPub Unity plugin. Only import the files under Assets/plugins/iOS/mopub/ from the MoPub Unity plugin. Uncheck the checkboxes for all other files.

Next, Download the latest version of the MoPub adapter and add the MoPubAdapter.framework to the Assets/Plugins/iOS directory in your Unity project.

Step 4: Additional Code Required

Android

Modify Android manifest

Activities

Include the following Activity declarations in your AndroidManifest.xml under the application tag:

<activity android:name="com.mopub.mobileads.MoPubActivity"
          android:configChanges="keyboardHidden|orientation|screenSize"/>

<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>

<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

iOS

No additional code required.

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 creative

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

Optional steps

Android

Permissions

If the user's location needs to be used for the targeting, MoPub recommends adding the following optional permission into your app's AndroidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

MoPub recommends adding the following optional permission for MRAID 2.0:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

iOS

No additional steps required for iOS integration.

Send feedback about...

AdMob for Unity
AdMob for Unity
Need help? Visit our support page.