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, how to set up Ad Network Optimization (ANO), and how to integrate the MoPub SDK and adapter into an iOS app.
Supported ad formats and features
The AdMob mediation adapter for MoPub has the following capabilities:
|Ad Network Optimization (ANO)|
- Xcode 6.0 or higher
- iOS Deployment target of 8.0 or higher
- Minimum required Google Mobile Ads SDK 7.14.0 or higher
Step 1: Set up MoPub
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 requires you to create your first Ad Unit before finishing 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 AdMob UI. So, we recommend using a high value for the Refresh Interval here (e.g. 1000 seconds).
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.
Choose Tablet as the Device type. Choose Native (Custom layout) as the Format. Enter a Name for your Ad Unit.
Click Save and View Code Integration to get your 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 AdMob ad unit ID. To find your API Key and Inventory Report ID, navigate to the Reports page and click View API Access Details.
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.
See the Marketplace setup guide for more details.
Step 2: Configure mediation settings for your AdMob ad unit
You need to add MoPub to the mediation configuration for your Ad Unit. First sign into your AdMob account.
Next, 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.
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.
Associate this mediation group with your existing AdMob ad unit. Then click Done.
You should now see the ad units card populated with the ad units you selected.
Add MoPub as an ad source
In the Ad Sources card, select Add Ad Network. Then select MoPub.
Enable the Optimize switch. Enter the API Key and Inventory Report ID obtained in the previous section to set up ANO for 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.
Finally, click Save.
Step 3: Import the MoPub SDK and adapter
Using CocoaPods (recommended)
Add the following line to your project's Podfile:
From the command line run:
pod install --repo-update
- Download the latest version of the
MoPub SDK and link the
MoPubSDKsource code in your project.
- Download the latest version of the
MoPubAdapter.frameworkin your project.
Step 4: 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.
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.
That's it! You now have a working mediation integration with MoPub.
EU Consent and GDPR
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
The MoPub adapter supports an additional request parameter which can be passed
to the adapter using the
GADMoPubNetworkExtras class. This class includes the
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:
let adRequest = GADRequest() let extras = GADMoPubNetworkExtras() extras.privacyIconSize = 15 adRequest.registerAdNetworkExtras(extras)
GADRequest *request = [GADRequest request]; GADMoPubNetworkExtras *extras = [[GADMoPubNetworkExtras alloc] init]; extras.privacyIconSize = 15; [adRequest registerAdNetworkExtras:extras];
|Field||Populated by MoPub adapter|
|Call to action|
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.
For more details on how to set up test ad units, see MoPub's Testing Ads guide.