Skip to main content

Ads

Another great way to monetize your game is by displaying advertisements. Below is the setup guide for our currently supported ads system: AdMob.

AdMob Overview

AdMob is a popular Google product designed specifically for mobile game and app monetization.

1. Linking Your App ID

To begin, you need to bind your game to your Google AdMob account.

  1. In Unity, go to the top menu and click Assets > Google Mobile Ads > Settings.
Navigate Admob
  1. This will open the AdMob settings inside your Inspector window.
Admob Settings
info

Google Mobile Ads App ID Inside these settings, the most crucial step is to paste your Google Mobile Ads App ID. This establishes the connection between your game and your Google AdMob account, ensuring you can track data and get credited for the ads shown!

2. Setting Up Ad Units

Once the game is linked to your account, you need to specify the exact ads you want to show using the AdMobService.cs script.

  1. In your Project window, search for and open AdMobService.cs.
Admob Service
  1. Inside the script, scroll down until you find the #if UNITY_ANDROID section.
Admob Unit Id

Ad Unit Setup Variables

Assigns the specific IDs to control which ads are displayed for each device platform.

Syntax:

#if [PlatformMacro]
private const string _interstitialAdUnitId = "[AdUnitID]";
private const string _rewardedAdUnitId = "[AdUnitID]";
private const string _bannerAdUnitId = "[AdUnitID]";

Parameters:

ParameterTypeOptionsDescription
PlatformMacrocodeUNITY_ANDROID, UNITY_IOSThe device platform you are targeting. (Use #else for other platforms like Fire OS or Huawei).
_interstitialAdUnitIdtextAdMob ID stringThe unique ID for full-screen ads.
_rewardedAdUnitIdtextAdMob ID stringThe unique ID for ads that give players a reward for watching.
_bannerAdUnitIdtextAdMob ID stringThe unique ID for small, continuous banner ads.

Examples:

#if UNITY_ANDROID
private const string _interstitialAdUnitId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
private const string _rewardedAdUnitId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
private const string _bannerAdUnitId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
#elif UNITY_IOS
// Insert your unique iOS Ad Unit IDs here
#else
// Insert IDs for other platforms (Fire OS, Huawei, etc.) here
#endif

Assigns the specific AdMob IDs for Android devices, while providing a dedicated space for Apple devices (iOS) and alternative platforms.

You're All Set!

Once everything is fully set up, your game is ready to display ads! The game will now automatically send data back to your AdMob account, allowing you to track exactly how many users are viewing ads inside your build.