Test Ads

This guide explains how to enable test ads in your ads integration. It's important to enable test ads during development so that you can click on them without charging Google advertisers. If you click on too many ads without being in test mode, you risk your account being flagged for invalid activity.

There are two ways to get test ads:

  1. Use one of Google's sample ad units.

  2. Use your own ad unit and enable test devices.

Prerequisites

Complete Get Started. Your Unity app should already have the Google Mobile Ads Unity plugin imported.

Sample ad units

The quickest way to enable testing is to use Google-provided test ad units. These ad units are not associated with your AdMob account, so there's no risk of your account generating invalid traffic when using these ad units.

It is important to note that different Google-provided test ad units should be used depending on the platform. You'll need to use an iOS test ad unit for making test ad requests on iOS and an Android test ad unit for making requests on Android.

Here are sample ad units for each format on both Android and iOS:

Android

Ad format Sample ad unit ID
Banner ca-app-pub-3940256099942544/6300978111
Interstitial ca-app-pub-3940256099942544/1033173712
Rewarded Video ca-app-pub-3940256099942544/5224354917
Native Advanced ca-app-pub-3940256099942544/2247696110

iOS

Ad format Sample ad unit ID
Banner ca-app-pub-3940256099942544/2934735716
Interstitial ca-app-pub-3940256099942544/4411468910
Rewarded Video ca-app-pub-3940256099942544/1712485313
Native Advanced ca-app-pub-3940256099942544/3986624511

These ad units point to specific test creatives.

Enable test devices

If you want to do more rigorous testing with production-looking ads, you can now configure your device as a test device and use your own ad unit IDs that you've created in the AdMob UI.

Follow the steps below to add your device as a test device.

Add your test device

  1. Run an app configured with the Mobile Ads SDK and make an ad request using one of the test ad unit IDs listed above. (The full code is listed here.)

    ...
    private void RequestBanner()
    {
      #if UNITY_ANDROID
          string adUnitId = "ca-app-pub-3940256099942544/6300978111";
      #elif UNITY_IPHONE
          string adUnitId = "ca-app-pub-3940256099942544/2934735716";
      #else
          string adUnitId = "unexpected_platform";
      #endif
     
      // Create a 320x50 banner at the top of the screen.
      bannerView = new BannerView(adUnitId, AdSize.Banner, AdPosition.Top);
      // Create an empty ad request.
      AdRequest request = new AdRequest.Builder().Build();
      // Load the banner with the request.
      bannerView.LoadAd(request);
    }
  2. Check the console or logcat output for a message that looks like this:

    Android

    <Google> To get test ads on this device, call:
    request.testDevices = @[ "2077ef9a63d2b398840261c8221a0c9b" ];

    iOS

    I/Ads: Use AdRequest.Builder.addTestDevice("33BE2250B43518CCDA7DE426D04EE232")
    to get test ads on this device.
  3. Copy your alphanumeric test device ID to your clipboard.

  4. Modify your code to call AddTestDevice() on your AdRequest with your test device ID. This method can be called multiple times for multiple devices.

    AdRequest request = new AdRequest.Builder()
      .AddTestDevice("2077ef9a63d2b398840261c8221a0c9b")
      .Build();
  5. Re-run your app. If you correctly added your device as a test device, you will see a Test Ad label centered at the top of banner, interstitial, and rewarded ads:

    Ads with this Test Ad label are safe to click. Any requests, impressions, and clicks on test ads do not show up in your account's reports.

  6. Now that your device is registered as a test device, you can begin receiving more realistic test ads by replacing the test adUnitID with your own adUnitID.

Testing with mediation

Google's sample ad units only show Google Ads. To test your mediation configuration, you must use the enable test devices approach.

Mediated ads do NOT render a Test Ad label. You are responsible for ensuring that test ads are enabled for each of your mediation networks so these networks don't flag your account for invalid activity. See each network's respective mediation guide for more information.

If you aren't sure whether a mediation ad network adapter supports test ads, it is safest to avoid clicking on ads from that network during development. You can use the MediationAdapterClassName() method on any of the ad formats to figure out which ad network served the current ad.

フィードバックを送信...

ご不明な点がありましたら、Google のサポートページをご覧ください。