Key Takeaways
- To add AdMob to Unity game projects, you install Google’s Mobile Ads plugin, set your AdMob app IDs, initialize the SDK once at launch and then load and show each ad format.
- Use Google’s test ad unit IDs or a registered test device during development. Never test with live ads.
- Interstitial and rewarded ads are one-time-use objects, so load a new one after each impression.
- Add a consent flow (Google’s UMP SDK) where required, and request ads only when consent allows it.
- Place ads at natural breaks and test on real devices.
Table of Contents
If you want to add AdMob to Unity game projects, the technical setup takes less than an hour. The details are what cause problems later: wrong ad IDs, ads requested before initialization, missing consent or ads that interrupt gameplay at the worst moment.
This guide walks through the full process step by step, from creating your AdMob ad units to showing banner, interstitial and rewarded ads, with C# code you can adapt. It follows Google’s official documentation, and the plugin changes over time, so check the linked pages for the current version before you build. We also cover consent, ad placement, testing and common mistakes.
Before You Start: Checklist to Add AdMob to Unity Game Projects
Prepare these items first.
| Requirement | What to check |
|---|---|
| Unity version | Google’s guide lists Unity 2019.4 or higher at the time of writing. Check the current requirement |
| Android | Minimum API level 23 and a target API level that meets the current guide (34 or higher when I checked) |
| iOS (optional) | Xcode, iOS version and CocoaPods requirements listed in the guide |
| AdMob account | An account with your app registered and at least one ad unit |
| Real test device | An Android or iOS phone for testing |
Prerequisites change between plugin releases, so treat the table as a starting point and read the official Unity quick start before you begin.
Step 1: Create Your AdMob Account, App and Ad Units
Sign in to AdMob, register your app for each platform and create one ad unit per format you plan to use: banner, interstitial and rewarded. Each ad unit has an ID that looks like a long string with a slash in the middle. You also get an app ID for each platform, which uses a tilde instead of a slash.
Keep the IDs in a safe note. You will use the app IDs in the Unity settings and the ad unit IDs in your scripts. Use separate IDs for Android and iOS, because each platform needs its own.
Step 2: Install the Google Mobile Ads Unity Plugin
Google documents two main ways to import the plugin: through OpenUPM (a scoped registry in the Unity Package Manager) or by importing a .unitypackage file from GitHub. OpenUPM is easier to update, and the .unitypackage is easier to inspect.
After import, the plugin uses a dependency resolver to bring in Android and iOS native libraries. On Android, run the resolver from the Assets menu if dependencies are not copied automatically, and enable the custom Gradle templates if the guide asks for them. If you migrate from the .unitypackage to OpenUPM, remove the old plugin folders first, as the guide explains, to avoid duplicates.
If you customize an existing Unity project that already contains ad code, check which ad SDKs are installed before you add another one. Our Unity game reskin vs remake guide explains what to review when you take over a ready-made project.
Step 3: Set Your App IDs and Initialize the SDK
In the Unity menu, open Assets > Google Mobile Ads > Settings and enter your Android and iOS AdMob app IDs. This step is required, and a missing or wrong app ID is a common reason for crashes at launch.
Then initialize the SDK once, ideally at app launch, by calling MobileAds.Initialize(). Google’s guide notes that ad events are raised off the Unity main thread. If you need to touch Unity objects in a callback, use MobileAdsEventExecutor.ExecuteInUpdate. If you use mediation, wait for the initialization callback before you load ads.
Step 4: Use Test Ads Only While Developing
Always test with Google’s test ad units or with your device registered as a test device. Google provides sample test ad unit IDs for each format and platform, and it warns that using real ads during development can create invalid traffic. Never click your own live ads.
The code below uses Google’s Android test IDs from its banner, interstitial and rewarded guides. For iOS and for the current values, copy the IDs from the official pages for interstitial ads and rewarded ads, because IDs differ by platform and format.
Step 5: Add Banner Ads
A banner is a rectangular ad that stays on screen. Create a BannerView with an ad unit ID, a size and a position, then load an ad with an AdRequest. Destroy the banner when you no longer need it.
On phones with notches or rounded corners, check that the banner does not collide with your interface. Our guide to the Unity mobile UI safe area explains how to keep UI in safe zones.
Step 6: Add Interstitial Ads at Natural Breaks
Interstitials are full-screen ads. Google recommends showing them at natural transition points, such as between levels, and pausing the action while the ad is on screen. Load the ad with InterstitialAd.Load, check CanShowAd() before showing it and load a new ad after the old one closes, because an interstitial object can be used only once.
Step 7: Add Rewarded Ads
Rewarded ads give players an in-game reward in exchange for watching. Load with RewardedAd.Load, check CanShowAd(), and pass a callback to Show() that grants the reward. A rewarded ad is also a one-time-use object, so preload the next one after the current ad closes. Call Destroy() on ad objects you no longer need, to avoid memory leaks.
Example Script for All Three Formats
This script follows the API shown in Google’s current documentation. Older plugin versions used a different API, so if you copied code from an old tutorial and see compile errors, update the plugin. It is a starting point, not a production-complete system. Test it in your Unity version before you rely on it.
using System;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdsManager : MonoBehaviour
{
// Google's Android TEST ad unit IDs. Replace with your own IDs before release.
// iOS IDs are different: copy them from Google's official pages.
private const string BannerId = "ca-app-pub-3940256099942544/6300978111";
private const string InterstitialId = "ca-app-pub-3940256099942544/1033173712";
private const string RewardedId = "ca-app-pub-3940256099942544/5224354917";
private BannerView _banner;
private InterstitialAd _interstitial;
private RewardedAd _rewarded;
private void Start()
{
MobileAds.Initialize((InitializationStatus status) =>
{
// Ad callbacks are raised off the main thread.
MobileAdsEventExecutor.ExecuteInUpdate(() =>
{
LoadInterstitial();
LoadRewarded();
});
});
}
public void ShowBanner()
{
if (_banner == null)
{
_banner = new BannerView(BannerId, AdSize.Banner, AdPosition.Bottom);
}
_banner.LoadAd(new AdRequest());
}
public void DestroyBanner()
{
if (_banner != null)
{
_banner.Destroy();
_banner = null;
}
}
private void LoadInterstitial()
{
if (_interstitial != null)
{
_interstitial.Destroy();
_interstitial = null;
}
InterstitialAd.Load(InterstitialId, new AdRequest(), (InterstitialAd ad, LoadAdError error) =>
{
if (error != null || ad == null) { return; }
_interstitial = ad;
// One-time-use object: load the next one after this ad closes or fails.
_interstitial.OnAdFullScreenContentClosed += () => MobileAdsEventExecutor.ExecuteInUpdate(LoadInterstitial);
_interstitial.OnAdFullScreenContentFailed += (AdError e) => MobileAdsEventExecutor.ExecuteInUpdate(LoadInterstitial);
});
}
public void ShowInterstitial()
{
if (_interstitial != null && _interstitial.CanShowAd())
{
_interstitial.Show(); // Pause gameplay and audio before calling this.
}
}
private void LoadRewarded()
{
if (_rewarded != null)
{
_rewarded.Destroy();
_rewarded = null;
}
RewardedAd.Load(RewardedId, new AdRequest(), (RewardedAd ad, LoadAdError error) =>
{
if (error != null || ad == null) { return; }
_rewarded = ad;
_rewarded.OnAdFullScreenContentClosed += () => MobileAdsEventExecutor.ExecuteInUpdate(LoadRewarded);
_rewarded.OnAdFullScreenContentFailed += (AdError e) => MobileAdsEventExecutor.ExecuteInUpdate(LoadRewarded);
});
}
public void ShowRewarded(Action onReward)
{
if (_rewarded != null && _rewarded.CanShowAd())
{
_rewarded.Show((Reward reward) =>
{
MobileAdsEventExecutor.ExecuteInUpdate(() => onReward?.Invoke());
});
}
}
}
What the script does: it initializes the SDK once, preloads an interstitial and a rewarded ad, shows a bottom banner on request and reloads each fullscreen ad after it closes. Grant the reward only inside the reward callback. A production version should also handle failed loads with a delayed retry, and respect consent.
Step 8: Handle User Consent with Google’s UMP SDK
In regions where consent is required, your app must collect it before requesting ads. Google’s UMP SDK guide for Unity says to call ConsentInformation.Update() at every app launch, show a form with ConsentForm.LoadAndShowConsentFormIfRequired(), and check ConsentInformation.CanRequestAds() before requesting ads. If a privacy options entry point is required, add a visible button that opens the privacy options form.
You create the privacy message in your AdMob account, under the Privacy and messaging section. The guide also explains how to test with a debug geography, such as the European Economic Area, on a test device.
private bool _adsInitialized;
private void Start()
{
ConsentInformation.Update(new ConsentRequestParameters(), OnConsentInfoUpdated);
}
private void OnConsentInfoUpdated(FormError error)
{
// Even if consent gathering fails, the SDK may use the previous session's consent.
ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
{
if (ConsentInformation.CanRequestAds() && !_adsInitialized)
{
_adsInitialized = true;
MobileAds.Initialize((InitializationStatus status) => { /* load your ads here */ });
}
});
}
In this pattern, you initialize ads only after consent allows it. Adapt the flow to your game, and ask a privacy professional if you are unsure about legal requirements.
Step 9: Test, Build and Release
Before release, run through this list on real devices.
| Check | Why it matters |
|---|---|
| Test ads show for banner, interstitial and rewarded | Confirms the integration works |
| Real ad unit IDs and app IDs are in the release build | Test IDs do not earn revenue |
| Test device code and debug consent settings are removed | Google asks you to remove test device IDs before release |
| Rewards are granted only after the reward callback | Prevents free rewards |
| Game and audio pause during full-screen ads | Better player experience |
| Consent form appears in a simulated EEA test | Confirms the consent flow |
| Memory stays stable after many ad loads | Checks that Destroy() is called |
Our Unity game QA checklist helps you test the rest of the build, and our Unity mobile game optimization guide explains how to keep performance steady when ads load.
Where to Place Ads Without Hurting Gameplay
Good ad placement protects player experience and still earns revenue. Use this table for a casual game as an illustrative example. It is not a rule.
| Placement | Format | Trigger | Why |
|---|---|---|---|
| Bottom of the level screen | Banner | Always visible during play | Low interruption, but check safe areas |
| After a level is completed | Interstitial | Natural pause between levels | Matches Google’s advice for natural breaks |
| Extra life or double coins button | Rewarded | Player chooses to watch | Player gets value |
| During active gameplay | None | Avoid | Interruptions frustrate players |
Interface design affects how ads feel. Our article on mobile game UI/UX design best practices shows how to keep screens readable.
A Hypothetical Example: Ad Plan for a Casual Puzzle Game
This example is illustrative, not a real project. A small team ships a 100-level puzzle game. It shows a banner at the bottom of level screens and a full-screen ad after every few completed levels, with the first levels ad-free so new players can learn the game. A rewarded button offers an extra hint, and the reward is granted only when the callback fires.
The team tests everything with test IDs, switches to real IDs in a separate release build, adds the consent flow and tests on a simulated EEA device. If you want help planning monetization or integration work, you can see an example of our work in our Drag Racing Unity source code project and our Flick Football 3D Unity project, which are examples of Unity mobile projects. We do not claim these projects use AdMob.
Troubleshooting: Ads Not Showing in Unity
| Symptom | Likely cause | What to try |
|---|---|---|
| No ads in the Editor | Ads often do not display in the Editor | Test on a device or in a build |
| Build crashes at launch | Missing or wrong app ID | Check Assets > Google Mobile Ads > Settings |
| Load fails with an error | Wrong ad unit ID, or an ID from the wrong platform | Check IDs and log the error message |
| Real ads do not show on a new unit | New ad units can take time to start serving | Wait and keep testing with test ads |
| Ads request fails after consent changes | Ads were requested before consent | Use CanRequestAds() before requests |
| Show does nothing | Ad object was used already or is not ready | Check CanShowAd() and reload after each show |
Common Mistakes When You Add AdMob to a Unity Game
- Testing with live ads. It risks invalid traffic and account problems.
- Initializing too late. Request ads only after the SDK is initialized.
- Reusing an ad object. Interstitial and rewarded ads must be reloaded after each show.
- Skipping consent. Apps in regulated regions need a proper flow.
- Granting rewards too early. Use the reward callback only.
- Showing ads at bad moments. Never interrupt active gameplay.
- Forgetting to replace IDs in bought source code. Always use your own app and ad unit IDs, and remove unknown ad SDKs.
- Not budgeting time for integration. Ads add design, coding and testing work, as we explain in our guide to the cost to make a mobile game in Unity.
Conclusion
To add AdMob to Unity game projects safely, follow a clear order: create your ad units, install the plugin, set app IDs, initialize once, test with test ads and then add banner, interstitial and rewarded formats with consent and good placement. The plugin evolves, so check Google’s documentation for your version before every release.
At GamePro Studio, we build Unity games, 3D art and game UI/UX for mobile, PC and VR. If you need help to add AdMob to Unity game projects or to plan monetization, you can start with our Unity game developer hiring service.
Frequently Asked Questions
Can I use AdMob with other ad networks in Unity?
Yes, through mediation, which lets several networks compete for an ad slot. Google’s guide notes that with mediation you should wait for the initialization callback before loading ads. Mediation needs extra setup per network.
Do I need to add the consent form to my game?
If your game serves ads to users in regions where consent is required, yes. Google’s UMP SDK is the documented way to manage it in AdMob. Ask a privacy professional if you are unsure about your legal duties.
Why do I see test ads in my release build?
You probably still use test ad unit IDs. Replace them with your real IDs for release, and remove test device and debug consent code.
How many interstitial ads are too many?
There is no fixed number. Show them at natural breaks, keep the first minutes ad-free, test with real players and watch retention.
Does adding ads make my game bigger or slower?
It adds the plugin and native libraries to your build, and ad loading uses memory and network. Measure your build size and performance before and after, and destroy ad objects when finished.