Integrating Unity Ads with Mediation

This guide is intended for publishers who want to use the Google Mobile Ads SDK to load and display ads from Unity Ads via mediation. It covers how to add Unity Ads to an ad unit's mediation configuration, how to set up Ad Network Optimization (ANO), and how to integrate the Unity Ads SDK and adapter into an Android app.

Supported ad formats and features

The AdMob mediation adapter for Unity Ads has the following capabilities:

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

Requirements

  • Android SDK 4.0 (API level 14) or later
  • Google Play services 9.0.0 or later

Step 1: Set up Unity ads

Create and login to your Unity ID. Navigate to your Unity Ads Dashboard and add your project to Unity dashboard by clicking the Add new project button.

Fill out the form and click Continue at the bottom of the page to add your project to Unity Dashboard.

Once your project is created, Unity will display instructions on how to integrate. You can skip these instructions but take a note of the Game ID for Google Play Store and click the OK, Got it! button at the bottom of the page.

Now create a new placement to be used with AdMob mediation. We recommend creating a new placement for mediation with AdMob even if you have a placement already. To create a new placement, select your project under the Projects tab in your Unity Ads Dashboard. Go to your Android app by selecting Google Play Store under the Platforms tab of your project.

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

Interstitial

Choose Skippable Video as the type. Enter the placement's Name and Unity Ads will generate your Placement ID based on the name.

Choose whether or not to mute audio for your ads and enter a time in seconds after which the user is allowed to skip the ad. Click Save to create your Placement.

Rewarded Video

Choose Rewarded Video as the type. Enter the placement's Name and Unity Ads will generate your Placement ID based on the name.

Choose whether or not to mute audio for your ads and click Save to create your Placement.

Once the ad placement is created, you can locate your Placement ID under the Ad placements tab.

In addition to the Game ID and the Placement ID you will also need Unity Ads API Key for setting up your AdMob ad unit ID. Navigate to the API keys tab in your Unity Ads Dashboard to get your API Key.

Step 2: Configure mediation settings for your AdMob ad unit

You need to add Unity Ads to the mediation configuration for your ad unit. First sign in to the AdMob UI.

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

AdMob

Navigate to the Monetize tab and select your app 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 Unity Ads.

Click + NEW AD NETWORK.

Select Unity Ads from the list of available ad networks and enter the Game ID and Placement ID obtained in the previous section.

Unity select unity

Enter your API Key obtained in the previous section to set up Ad Network Optimization (ANO) for Unity Ads.

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

AdMob Beta

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 Unity Ads 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.

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

Mediation group ad units

Add Unity Ads as an ad source

In the Ad Sources card, select Add Ad Network. Then select Unity Ads.

Enable the Optimize switch. Enter your API Key obtained in the previous section to set up ANO for Unity Ads. Then enter an eCPM value for Unity Ads and click Continue.

Next, enter the Game ID and Placement ID obtained in the previous section. Then click Done.

Finally, click Save.

Using rewarded video ads

In the settings for your rewarded video ad unit, check the Override reward settings from third-party ad networks when using AdMob mediation so that you provide the same reward to the user no matter which ad network is served.

If you don't override the reward, the Unity adapter defaults to a reward of type "" (empty string) with value 1. The Unity Ads SDK does not provide specific reward values for its rewarded video ads.

For more information on setting reward values for AdMob ad units, see Create an ad unit.

Step 3: Import the Unity Ads SDK and adapter

Download the latest Unity Ads SDK (unity-ads.aar) from GitHub. Add the unity-ads.aar to your libs folder (create a libs folder if you don't have one).

Add the following gradle dependencies with the latest versions of the Unity Ads SDK and adapter in your app-level build.gradle file:

...
dependencies {
    implementation 'com.android.support:appcompat-v7:xx.x.x'
    implementation 'com.google.android.gms:play-services-ads:11.6.2'
    implementation 'com.unity3d.ads:unity-ads:2.1.2'
    implementation 'com.google.ads.mediation:unity:2.1.2.0'
}
...

Manual integration

Download the latest Unity Ads SDK (unity-ads.aar) from GitHub. Add the unity-ads.aar to your project.

Download the latest version of the Unity adapter from Bintray, located under the Files tab and add it to your project.

Step 4: Additional code required

No Additional code is required for Unity ads integration.

Step 5: Test your implementation

Test ads can be enabled from the Unity Ads dashboard by going to your project's platform specific settings. Under the TEST MODE section, toggle the override client test mode switch to on and choose the Force test mode ON to enable test ads.

Unity test mode

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

发送以下问题的反馈:

此网页
AdMob for Android
AdMob for Android
需要帮助?请访问我们的支持页面