Ads are the main way most free mobile games earn money, and Google AdMob is the most widely used ad network for Unity games. This guide shows how to add AdMob to a Unity game using the official Google Mobile Ads Unity plugin: installing the plugin, setting your App ID, initializing the SDK and showing banner, interstitial and rewarded ads. It also covers the steps people most often miss before release.
Before you start
- A Unity project with the Android and/or iOS build modules installed.
- An AdMob account with your app added. You get an App ID for each platform and an ad unit ID for each ad format you create.
- Google’s official test ad unit IDs for development. Never click your own live ads while testing; it can get your account suspended.
Many projects in our Unity source code store already include AdMob, so you only need to replace the IDs. The steps below also explain what that integration does under the hood.
Step 1: Install the Google Mobile Ads Unity plugin
The recommended way is through OpenUPM:
- Open Edit > Project Settings > Package Manager and add a scoped registry: name
OpenUPM, URLhttps://package.openupm.com, scopecom.google. - Open Window > Package Manager, choose My Registries, select Google Mobile Ads for Unity and click Install.
Alternatively, download the latest .unitypackage from the plugin’s GitHub releases and import it with Assets > Import Package > Custom Package. If you are switching from an old .unitypackage install to OpenUPM, delete the old Assets/GoogleMobileAds and Assets/ExternalDependencyManager folders first.
Step 2: Set your AdMob App ID
Open Assets > Google Mobile Ads > Settings and paste your Android and iOS App IDs. The app will crash on launch if the App ID is missing, so this step is required even before you load any ads.
Step 3: Initialize the SDK
Initialize once when the game starts, for example from a bootstrap or GameManager script:
using GoogleMobileAds.Api;
using UnityEngine;
public class AdsBootstrap : MonoBehaviour
{
void Start()
{
MobileAds.Initialize(initStatus =>
{
// SDK is ready. Load your first ads here.
});
}
}
If you need user consent (for example for players in the EU or UK), collect it with Google’s User Messaging Platform before requesting ads. Ad callbacks can run off Unity’s main thread, so if a callback changes Unity objects, run that code through MobileAdsEventExecutor.ExecuteInUpdate.
Step 4: Show a banner ad
BannerView banner;
void ShowBanner(string adUnitId)
{
banner = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
banner.LoadAd(new AdRequest());
}
void HideBanner()
{
banner?.Destroy();
}
Place banners where they do not cover buttons or gameplay, typically at the bottom of menus.
Step 5: Show an interstitial ad
Interstitials are full-screen ads shown at natural breaks, such as between levels or after game over.
InterstitialAd interstitial;
void LoadInterstitial(string adUnitId)
{
InterstitialAd.Load(adUnitId, new AdRequest(), (InterstitialAd ad, LoadAdError error) =>
{
if (error != null) return;
interstitial = ad;
});
}
void ShowInterstitial()
{
if (interstitial != null && interstitial.CanShowAd())
interstitial.Show();
}
Step 6: Show a rewarded ad
Rewarded ads let players choose to watch an ad in exchange for a reward, such as a hint, extra life or coins. Players like them because they are optional, and they usually earn the most per view.
RewardedAd rewarded;
void LoadRewarded(string adUnitId)
{
RewardedAd.Load(adUnitId, new AdRequest(), (RewardedAd ad, LoadAdError error) =>
{
if (error != null) return;
rewarded = ad;
});
}
void ShowRewarded()
{
if (rewarded != null && rewarded.CanShowAd())
{
rewarded.Show((Reward reward) =>
{
// Give the player their reward here.
});
}
}
A good example is the hint system in 1Line One Stroke Puzzle, where players earn free hints by watching rewarded videos.
Step 7: Test, then switch to live IDs
- Use Google’s test ad unit IDs, or register your phone as a test device, during development.
- Build to a real device and check every ad loads and closes correctly.
- Replace test IDs with your live ad unit IDs only for the release build.
- Add an
app-ads.txtfile to your developer website so advertisers can verify your inventory.
Where to place ads without hurting your game
- Show interstitials between levels, not during gameplay, and not after every single level.
- Offer rewarded ads for things players actually want, like continues, hints or double coins.
- Add a paid “Remove Ads” option for players who prefer to pay. Projects such as Tap It Away 3D Block Puzzle include it already.
Frequently asked questions
Why does my Unity game crash on start after adding AdMob?
The most common cause is a missing App ID in Assets > Google Mobile Ads > Settings. Also make sure Android dependencies were resolved by the External Dependency Manager.
Can I use AdMob and Unity Ads together?
Yes. You can use AdMob mediation to fill ads from several networks, or integrate both SDKs separately. Several projects in our store, such as 2D Tower Defense, already include both.
Why are no ads showing?
New ad units can take a while to start serving, and live ads often do not fill in the editor. Test on a device with test IDs first, then check your AdMob account and app status.
Want a game with ads already wired in? Browse our Unity source code and swap in your own IDs.

