Configure AdMob for Unity Mediation

Publishers can use Unity Mediation to load and display ads from AdMob through waterfall mediation.

Note: If you are using AdMob and are building for Android 31+, you must add the following temporary dependency to Gradle:

implementation "androidx.work:work-runtime:2.7.0"

Prerequisites

Before you begin, create an AdMob account: https://apps.admob.com/signup.

If your game is made with Unity, install the AdMob Adapter to your project:

  1. Open your project in the Unity Editor.

  2. Select Edit > Project Settings > Services > Mediation or Services > Mediation > Configure.

  3. In the Adapter Configuration section, find the AdMob Adapter.

    1. Enter your AdMob app IDs.

      Caution: You must enter your AdMob app IDs before you install the AdMob Adapter to prevent your project from crashing.

      To retrieve your AdMob app IDs, on the AdMob dashboard, in the left menu, select Apps > VIEW ALL APPS. Find your app in the list, copy its app ID for each platform, and then enter them into the respective fields in the Unity Editor.

    2. Select Install.

      Note: Installing the AdMob Adapter through the Unity Editor also pulls in the AdMob SDK.

Add an app to your AdMob account

To add an app to your AdMob account, complete the following steps.

  1. Sign in to your AdMob account: https://apps.admob.com/.

  2. In the left navigation menu, select Apps.

  3. Select Add App, and then fill out the requested information.

    Note: AdMob requires one unique app per platform.
  4. Select Add App.

Create ad units in the AdMob dashboard

Important: The AdMob network allows up to three calls for the same ad request. This means that you can set up no more than three line items of the same ad format within the same waterfall. For example, one waterfall can only have three Interstitial ad line items with AdMob as an Ad Source.
  1. When you successfully add your app in your AdMob account, you are prompted to create an ad unit.

    Note: Alternatively, from the AdMob app overview page, in the left menu, select Apps > Ad Units.
  2. Select an ad format.

  3. Name the ad unit as contextually as possible so you can easily recognize it in the Unity Mediation platform then complete the rest of the fields and select CREATE AD UNIT.

    Note: For more information on naming convention best practices, see Ensure standardized line syntax.

When you create the Ad Unit, the App ID and Ad Unit ID are also generated. Save these IDs to use when you create waterfall line items for AdMob (or refer to them in the AdMob dashboard: in the left navigation menu, select Apps > Ad Units).

Retrieve your AdMob credentials

When you first set up the AdMob Ad Source in the Unity Dashboard for your project, you need to enter your AdMob publisher account credentials for the Client ID, Client Secret ID, and Publisher ID.

To do this, use one of the following methods:

Manually retrieve your AdMob credentials

  1. Go to Google’s APIs & Services manager: https://console.cloud.google.com/apis.

  2. On the Credentials page, from the left navigation menu, select Credentials > OAuth Client ID.

  3. Select the Application type, enter the name, and then select Create.

    Result: A modal displays with your Client ID and Client Secret

Sign in by using OAuth

To sign in with your AdMob publisher account and pull in all the required credentials automatically into the Unity Dashboard, complete the following steps:

  1. On the Unity Monetization Dashboard, from the left navigation menu, select Mediation > Ad Sources.

  2. Find Google AdMob in the list of Ad Sources and select Activate.

  3. Select Sign in with Google. A Google OAuth sign-in dialog opens so you can confirm what unity3d.com (the Unity Dashboard) can access from your AdMob publisher account.

  4. Select a Google publisher account to sign in with.

  5. Ensure that unity3d.com (the Unity Dashboard) can access everything (this includes enabling the See your AdMob data checkbox), and then select Continue.

Result: When you return to the AdMob Ad Source setup page in the Unity Dashboard, if the OAuth sign-in is successful, then setup is complete.

However, if the OAuth sign-in fails, then this might be due to any of the following reasons:

  • You did not enable the See your AdMob data checkbox when you signed in with your AdMob account.

  • You do not have an AdMob publisher account associated with the account that you are using to sign in.

  • You have multiple AdMob publisher accounts.

    To troubleshoot this, manually enter the credentials of the AdMob publisher account that you want to use in the Unity Dashboard AdMob Ad Source setup.

  • There is a technical error with your AdMob publisher account.

    To troubleshoot this, go to your selected AdMob publisher account to verify the credentials, and then try again to manually enter the credentials into the AdMob Ad Source setup.

Retrieve your Refresh Token

To retrieve your Refresh Token, complete the following steps:

  1. Go to the OAuth 2.0 Playground: https://developers.google.com/oauthplayground/.

  2. Select the Gear to expand the OAuth 2.0 Configuration panel.

  3. Ensure that Use your own OAuth credentials is enabled.

  4. Input your ClientID and Client Secret, and then select Close.

  5. In the OAuth 2.0 Playground window, under Step 1: Select & Authorize APIs, enter https://www.googleapis.com/auth/admob.report into the text field, and then select Authorize APIs.

  6. Allow your project access to your AdMob data.

  7. You are given an authorization code. Select Exchange authorization code for tokens to receive a Refresh Token and Access Token.

Retrieve your Publisher ID

To retrieve your Publisher ID, complete the following steps:

  1. From the left navigation menu of your AdMob account, select Settings.

  2. Go to Account Information.

    Your Publisher ID is listed on this tab.

Configure the AdMob Ad Source in the Unity Dashboard

To configure AdMob as a third-party Ad Source in Unity Mediation, complete the following steps.

  1. On the Unity Monetization Dashboard, select Mediation > Ad Sources.

  2. Find Google AdMob in the list of Ad Sources and select Activate.

  3. Complete the fields with the credentials from your AdMob account:

    • Enter the Client ID, Client Secret, Refresh Token, and Publisher ID in the corresponding fields.

    • Enable the Reporting Access Authorization checkbox.

  4. Select Complete.

Create an AdMob line item

Prerequisites: Create a waterfall, Configure the AdMob Ad Source, and Install the AdMob Adapter and SDK

To create an AdMob line item, complete the following steps:

Important: The AdMob network allows up to three calls for the same ad request. This means you can set up no more than three line items of the same ad format within the same waterfall. For example, one waterfall can only have three Interstitial ad line items with AdMob as an Ad Source.
  1. On the Unity Monetization Dashboard, select the Waterfalls page, and then select the waterfall that you want to add a line item to.

  2. In the Sort by eCPM Target or Auto - eCPM (Backfill) section, select Add Line Item.

  3. Select AdMob, and then select Next.

  4. Map line items to the Ad Source.

    1. Enter a line item name.

      Note: For more information on naming convention best practices, see Ensure standardized line syntax.
    2. Enter the Ad Unit ID.

    3. Set an eCPM target that reflects the estimated price expected from the Ad Source.

      Note: The eCPM target is only for defining the order in which ad networks are called, and has no role in the acceptance or rejection of an ad due to a price point.
  5. Select Save.