Get Started

This guide is intended for publishers who want to monetize a Unity app with AdMob and aren't using Firebase.

Integrating the Google Mobile Ads Unity plugin into an app, which you will do here, is the first step toward displaying AdMob ads and earning revenue. Once the integration is complete, you can choose an ad format (such as native or rewarded video) to get detailed implementation steps.

Prerequisites

Download the Mobile Ads Unity plugin

The Google Mobile Ads Unity plugin enables Unity developers to easily serve Google Mobile Ads on Android and iOS apps without having to write Java or Objective-C code. The plugin provides a C# interface for requesting ads that is used by C# scripts in your Unity project. Use the links below to download the Unity package for the plugin or to take a look at its code on GitHub.

DOWNLOAD THE PLUGIN VIEW SOURCE

Import the Mobile Ads Unity plugin

Open your project in the Unity editor. Select Assets > Import Package > Custom Package and find the GoogleMobileAdsPlugin.unitypackage file you downloaded.

Make sure all of the files are selected and click Import.

Include the Mobile Ads SDK

The Google Mobile Ads Unity plugin is distributed with the Unity Play Services Resolver library. This library is intended for use by any Unity plugin that requires access to Android specific libraries (e.g., AARs) or iOS CocoaPods. It provides Unity plugins the ability to declare dependencies, which are then automatically resolved and copied into your Unity project.

Follow the steps listed below to ensure your project includes the Mobile Ads SDK.

Android

In the Unity editor, select Assets > Play Services Resolver > Android Resolver > Resolve. The Unity Play Services Resolver library will copy the declared dependencies into the Assets/Plugins/Android directory of your Unity app.

iOS

No additional steps are required to include the Mobile Ads SDK into the Unity project.

  • When using Unity 5.6 and above, an xcworkspace is generated that includes the required dependency libraries. Use the generated xcworkspace instead of the standard Xcode project.
  • When using older versions of Unity, the dependencies are included inside the standard Xcode project.

Unity 4 compatibility

If you're using Unity 4, follow the additional steps listed below.

Android

Add the highlighted activity section below to the AndroidManifest.xml file located in the Assets/Plugins/Android/GoogleMobileAdsPlugin directory of your Unity project.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="com.google.unity"
   android:versionName="1.0"
   android:versionCode="1">
 <uses-sdk android:minSdkVersion="14"
     android:targetSdkVersion="19" />
 <application>
 <activity android:name="com.unity3d.player.UnityPlayerNativeActivity"
   android:label="@string/app_name">
   <intent-filter>
     <action android:name="android.intent.action.MAIN" />
     <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
   <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik"
       android:value="true" />
</activity>
 </application>
</manifest>

iOS

Modify the following build settings within the Xcode project generated by Unity:

  1. Set Enable Modules (C and Objective-C) to Yes in Build Settings.
  2. Add $(inherited) to Other Linker Flags in Build Settings.

Initialize MobileAds

Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.Initialize() with your AdMob App ID. This needs to be done only once, ideally at app launch. You can find your app's App ID in the AdMob UI.

Here's an example of how to call Initialize() within the Start() method of a script attached to a GameObject:

...
using GoogleMobileAds.Api;
...
public class GoogleMobileAdsDemoScript : MonoBehaviour
{
    private BannerView bannerView;
    …
    public void Start()
    {
        #if UNITY_ANDROID
            string appId = "ca-app-pub-3940256099942544~3347511713";
        #elif UNITY_IPHONE
            string appId = "ca-app-pub-3940256099942544~1458002511";
        #else
            string appId = "unexpected_platform";
        #endif

        // Initialize the Google Mobile Ads SDK.
        MobileAds.Initialize(appId);
    }
}

Note how a different App ID is used, depending on the platform. You'll need to use an iOS App ID to initialize the Mobile Ads SDK on iOS and an Android App ID to initialize the Mobile Ads SDK on Android.

Select an ad format

The Mobile Ads SDK is now included in your Unity app when deploying to either the Android or iOS platform. You're now ready to implement an ad. AdMob offers a number of different ad formats, so you can choose the one that best fits your user experience needs.

Banner ads are rectangular image or text ads that occupy a spot within an app's layout. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.

Implement a Banner

Interstitial

Interstitials are full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or just after completing a task.

Implement an Interstitial

Native

Native is a component-based ad format that gives you the freedom to customize the way assets such as headlines and calls to action are presented in their apps. By choosing fonts, colors, and other details for yourself, you can create natural, unobtrusive ad presentations that can add to a rich user experience.

The Google Mobile Ads Unity plugin supports Native Ads Express. Native Ads Express has been designed to make the deployment of native ads as easy as possible, and it's a great choice if you are new to the format. Native Ads Advanced maximizes the degree of freedom you have in creating your presentations. It's currently in a closed beta with a limited group of publishers.

Implement Native Ads Express

Rewarded Video

Rewarded video ads are full-screen video ads that users have the option of watching in their entirety in exchange for in-app rewards.

Implement Rewarded Video

Send feedback about...

AdMob for Unity
AdMob for Unity
Need help? Visit our support page.