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 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:

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

Requirements

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

Step 1: Set up Unity ads

Sign up or log in to Unity Ads.

On the Unity Ads Dashboard, navigate to the Project tab and click the New Project button.

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

Once your project is created, navigate to the Monetization > Placements tab of your project and take note of the Game ID.

To create a new placement, click the Add Placement button.

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

Enter your desired Placement ID, select Banner as the ad format and click Create Placement.

Interstitial

Enter your desired Placement ID, select Interstitial Video as the ad format and click Create Placement.

Rewarded Video

Enter your desired Placement ID, select Rewarded Video as the ad format and click Create Placement.

In addition to the Game ID and Placement ID you will also need your Unity Ads API Key and Organization core ID for setting up your Ad Manager ad unit ID.

Navigate to the Ads Data Export > API Access tab of the Unity Ads Dashboard and take note of the Monetization Stats API Access Key.

Then, navigate to the Settings tab of the Unity Ads Dashboard and take note of the Organization core ID.

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 and Organization core ID 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 type "" (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

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

    pod 'GoogleMobileAdsMediationUnity'
    
  • From the command line run:

    pod install --repo-update

Manual integration

  • 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 in two ways.

If you want to enable test ads for all devices, navigate to the Settings > Project Settings tab of your project. Under the Test Mode section, edit the Client test mode not overridden section, check Override client test mode box, select Force test mode ON and click Save.

If you want to enable test ads only for specific devices, navigate to the Ads Data Export > Test Devices tab. Under the Test Devices section, click the Add New Device button and fill out the resulting form.

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.

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];

Unity Ads iOS Mediation Adapter Changelog

Version 3.5.0.0

  • Verified compatibility with unity ads SDK 3.5.0.
  • Added support for Adaptive Banner ads.
  • Now requires Google Mobile Ads SDK version 7.68.0 or higher.

Built and tested with

  • Google Mobile Ads SDK version 7.68.0.
  • Unity Ads SDK version 3.5.0.

Version 3.4.8.0

  • Verified compatibility with unity ads SDK 3.4.8.
  • Now requires Google Mobile Ads SDK version 7.63.0 or higher.

Built and tested with

  • Google Mobile Ads SDK version 7.63.0.
  • Unity Ads SDK version 3.4.8.

Version 3.4.6.0

  • Verified compatibility with unity ads SDK 3.4.6.
  • Now requires Google Mobile Ads SDK version 7.60.0 or higher.

Built and tested with

  • Google Mobile Ads SDK version 7.60.0.
  • Unity Ads SDK version 3.4.6.

Version 3.4.2.2

  • Added standardized adapter error codes and messages.
  • Updated the minimum required Google Mobile Ads SDK version to 7.59.0.

Built and tested with

  • Google Mobile Ads SDK version 7.59.0.
  • Unity Ads SDK version 3.4.2.

Version 3.4.2.1

  • Improved forwarding of Unity's errors to recognize initialization and ad load failures earlier and reduce timeouts.
  • Removed support for the i386 architecture.

Built and tested with

  • Google Mobile Ads SDK version 7.57.0.
  • Unity Ads SDK version 3.4.2.

Version 3.4.2.0

  • Verified compatibility with unity ads SDK 3.4.2.

Built and tested with

  • Google Mobile Ads SDK version 7.55.1.
  • Unity Ads SDK version 3.4.2.

Version 3.4.0.0

  • Verified compatibility with unity ads SDK 3.4.0.
  • Now supports loading multiple banner ads at once.

Built and tested with

  • Google Mobile Ads SDK version 7.53.0.
  • Unity Ads SDK version 3.4.0.

Version 3.3.0.0

  • Verified compatibility with unity ads SDK 3.3.0.
  • Now supports loading multiple banner ads at once.

Built and tested with

  • Google Mobile Ads SDK version 7.51.0.
  • Unity Ads SDK version 3.3.0.

Version 3.2.0.1

  • Verified compatibility with Unity Ads SDK 3.2.0.
  • Now requires Google Mobile Ads SDK version 7.46.0 or higher.
  • Fixed an issue where Unity Banner ads would fail to show when loaded.
  • Fixed an issue where the adapter was not properly forwarding the unityAdsReady callback.

Version 3.2.0.0

  • Release was removed due to a regression on no-fill reporting.

Version 3.1.0.0

  • Verified compatibility with Unity Ads SDK 3.1.0.

Version 3.0.3.0

  • Verified compatibility with Unity Ads SDK 3.0.3.
  • Now requires Google Mobile Ads SDK version 7.42.2 or higher.
  • Added support for flexible banner ad sizes.
  • Fixed an issue where Unity Banner ads would only successfully load once per session.

Version 3.0.1.0

  • Verified compatibility with Unity Ads SDK 3.0.1.
  • Fixed a crash that occurred when deallocating rewarded ads.

Version 3.0.0.3

  • Updating adapter to use new rewarded API.
  • Now requires Google Mobile Ads SDK version 7.41.0 or higher.

Version 3.0.0.2

  • Added support for banner ads.

Version 3.0.0.1

  • Fixed an issue where the adapter stores the 'placementId' of previous request.

Version 3.0.0.0

  • Verified compatibility with Unity Ads SDK 3.0.0.

Version 2.3.0.0

  • Verified compatibility with Unity Ads SDK 2.3.0.

Version 2.2.1.1

  • Added adapterDidCompletePlayingRewardBasedVideoAd: callback to the adapter.

Version 2.2.1.0

  • Verified compatibility with Unity Ads SDK 2.2.1.

Version 2.2.0.0

  • Verified compatibility with Unity Ads SDK 2.2.0.

Version 2.1.2.0

  • Verified compatibility with Unity Ads SDK 2.1.2.
  • Removed the support for 'armv7s' architecture.

Version 2.1.1.0

  • Verified compatibility with Unity Ads SDK 2.1.1.

Version 2.1.0.0

  • Updated the adapter to make it compatible with Unity Ads SDK 2.1.0.

Version 2.0.8.0

  • Verified compatibility with Unity Ads SDK 2.0.8.

Version 2.0.7.0

  • Adapter now tracks Unity Ads clicks so the AdMob and the Unity Ads click statistics can match up.
  • Apps now get interstitialWillLeaveApplication: and rewardBasedVideoAdWillLeaveApplication: callbacks.

Version 2.0.6.0

  • Verified compatibility with Unity Ads SDK 2.0.6.

Version 2.0.5.0

  • Verified compatibility with Unity Ads SDK 2.0.5.

Version 2.0.4.0

  • Changed the version naming system to [Unity Ads SDK version].[adapter patch version].
  • Updated the minimum required Unity Ads SDK to v2.0.4.
  • Updated the minimum required Google Mobile Ads SDK to v7.10.1.

Version 1.0.2

  • Made the user reward item's key non nil. The reward key will always be an empty or a valid string.

Version 1.0.1

  • Fixed bug where the rewardBasedVideoAdDidOpen: callback wasn’t getting called.

Version 1.0.0

  • Supports interstitial and reward-based video ads.