How To Add Google Ads In Unity Game

Integrating Google Ads into your Unity game can be an effective means of monetizing and earning income from your game. This article will provide step-by-step instructions on how to add Google Ads to your Unity game, based on my personal experiences.

Step 1: Set Up a Google AdMob Account

The first step in adding Google Ads to your Unity game is to set up a Google AdMob account. AdMob is a mobile advertising platform provided by Google that allows you to monetize your mobile applications.

To set up an AdMob account, visit the AdMob website and sign in with your Google account. Once you’re signed in, you’ll need to provide some basic information about your app and set up payment details.

Step 2: Create an Ad Unit

After setting up your AdMob account, the next step is to create an ad unit. An ad unit represents a space in your game where ads will be displayed. To create an ad unit, go to the AdMob dashboard and click on the “Monetize new app” button. Select the platform (in this case, Unity) and follow the instructions to create an ad unit.

Step 3: Import the Google Mobile Ads Unity Plugin

Now that you have set up your AdMob account and created an ad unit, you need to import the Google Mobile Ads Unity Plugin into your Unity project.

First, download the Google Mobile Ads Unity Plugin from the Google Ads GitHub repository. Import the downloaded package into your Unity project by going to Assets -> Import Package -> Custom Package and selecting the downloaded package file.

Step 4: Add the Ad Unit ID to your Game

Once the plugin is imported, you need to add the Ad Unit ID to your game. Open the Unity editor and navigate to the script that will handle ad display. Add the following code to initialize the Google Mobile Ads SDK and load the ad:


using GoogleMobileAds.Api;

public class AdManager : MonoBehaviour
{
private BannerView bannerView;

private void Start()
{
MobileAds.Initialize(initStatus => { });

bannerView = new BannerView("YOUR_AD_UNIT_ID", AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
bannerView.LoadAd(request);
}
}

Replace “YOUR_AD_UNIT_ID” with the ad unit ID you created in Step 2.

Step 5: Display Ads in your Game

Now that you have set up the ad unit ID, you can display ads in your game. To display a banner ad, add the following code to the appropriate section of your game:


private void DisplayBannerAd()
{
bannerView.Show();
}

private void HideBannerAd()
{
bannerView.Hide();
}

You can call the DisplayBannerAd() method to show the banner ad and the HideBannerAd() method to hide it.

Conclusion

Adding Google Ads to your Unity game can be a profitable decision, allowing you to generate revenue while providing users with a free or low-cost gaming experience. By following the steps outlined in this article, you can seamlessly integrate Google Ads into your Unity game and start monetizing it. Remember to experiment with ad placement and optimize your ads to maximize revenue without negatively impacting the user experience. Good luck!