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 Automatic data collection, and how to integrate the Unity Ads SDK and adapter into an iOS app.
Supported ad formats and features
The Ad Manager mediation adapter for Unity Ads has the following capabilities:
|Rewarded Video (new APIs)|
|Native Ads - Custom Rendering|
|Automatic data collection|
- Xcode 9.2 or higher
- iOS Deployment target of 8.0 or higher
- Google Mobile Ads SDK 7.42.2 or higher
Step 1: Set up Unity ads
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 Apple App Store and click the OK, Got it! button at the bottom of the page.
Now create a new placement to be used with Ad Manager mediation. We recommend creating a new placement for mediation with Ad Manager 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 iOS app by selecting Apple App 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.
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.
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 Ad Manager 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 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 Unity Ads, you can simply select it. Otherwise, select Create a new yield partner.
Select UnityAds as the Ad network and enter a unique Name. Enable Mediation and turn on Automatic data collection, and enter the API Key obtained in the previous section. You don't need to enter a Username and Password. Click Save when done.
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 Game ID and the Placement 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.
If you don't apply this setting, the Unity adapter defaults to a reward of
"" (empty string) with a value of
1. The Unity Ads SDK does not provide
specific reward values for its rewarded video ads.
Step 3: Import the Unity Ads 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 Unity Ads SDK, and link UnityAds.framework in your project.
Download the latest version of the Unity adapter and link UnityAdapter.framework in 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.
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.
Follow the instructions below to enable or disable personalized ads for Unity Ads.
Unity Ads provides a GDPR Compliance guide that describes both automatic and manual solutions for user consent.
The following sample code shows how to pass consent information to the Unity Ads SDK manually. Should you choose to pass consent information to the Unity Ads SDK manually, it is recommended that this code is called prior to requesting ads via the Google Mobile Ads SDK.
UADSMetaData *gdprConsentMetaData = [[UADSMetaData alloc] init]; [gdprConsentMetaData set:@"gdpr.consent" value:@YES]; [gdprConsentMetaData commit];