Targeting

This guide explains how to provide targeting information to an ad request.

To see ad targeting in action, download the Android API Demo app.

Download API Demo

Prerequisite

AdRequest

The AdRequest object collects targeting information to be sent with an ad request.

Location

If a user has granted your app location permissions, AdMob automatically passes this location data to the SDK. The SDK uses this data to improve ad targeting without requiring any code changes in your app. You can, of course, enable or disable location data for ads.

Autopopulated location information is not forwarded to mediation networks and it may also be disabled entirely. Therefore, the SDK provides the ability to set location manually. You can specify location-targeting information in the AdRequest as follows:

Java

AdRequest request = new AdRequest.Builder()
        .setLocation(location)
        .build();

Kotlin

val request = AdRequest.Builder()
        .setLocation(location)
        .build()

The user's location should be obtained by a suitable method.

Out of respect for user privacy, Google asks that you specify location only if that information is already being used by your app.

Child-directed setting

For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called "tag for child-directed treatment". By setting this tag, you certify that this notification is accurate and you are authorized to act on behalf of the owner of the app. You understand that abuse of this setting may result in termination of your Google account.

As an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request. If you indicate that you want Google to treat your content as child-directed, we take steps to disable IBA and remarketing ads on that ad request. The setting can be used with all versions of the Google Play services SDK via AdRequest.Builder.tagForChildDirectedTreatment(boolean):

  • Set tagForChildDirectedTreatment to true to indicate that you want your content treated as child-directed for purposes of COPPA.
  • Set tagForChildDirectedTreatment to false to indicate that you don't want your content treated as child-directed for purposes of COPPA.
  • Do not set tagForChildDirectedTreatment if you do not wish to indicate how you would like your content treated with respect to COPPA in ad requests.

The following example indicates that you want your content treated as child-directed for purposes of COPPA:

Java

AdRequest request = new AdRequest.Builder()
        .tagForChildDirectedTreatment(true)
        .build();

Kotlin

val request = AdRequest.Builder()
        .tagForChildDirectedTreatment(true)
        .build()

You can mark your ad requests to receive treatment for users in the European Economic Area (EEA) under the age of consent. This feature is designed to help facilitate compliance with the General Data Protection Regulation (GDPR). Note that you may have other legal obligations under GDPR. Please review the European Union’s guidance and consult with your own legal counsel. Please remember that Google's tools are designed to facilitate compliance and do not relieve any particular publisher of its obligations under the law. Learn more about how the GDPR affects publishers.

When using this feature, a Tag For Users under the Age of Consent in Europe (TFUA) parameter will be included in the ad request. This parameter disables personalized advertising, including remarketing, for that specific ad request. It also disables requests to third-party ad vendors, such as ad measurement pixels and third-party ad servers.

The setting can be used with all versions of the Google Mobile Ads SDK by using the tag_for_under_age_of_consent network extra.

  • Set tag_for_under_age_of_consent to true to indicate that you want the ad request to be handled in a manner suitable for users under the age of consent.
  • Not setting tag_for_under_age_of_consent indicates that you don't want the ad request to be handled in a manner suitable for users under the age of consent.

The following example indicates that you want TFUA included in your ad request:

Java

Bundle extras = new Bundle();
extras.putBoolean("tag_for_under_age_of_consent", true);

AdRequest request = new AdRequest.Builder()
        .addNetworkExtrasBundle(AdMobAdapter.class, extras)
        .build();

Kotlin

val extras = Bundle()

extras.putBoolean("tag_for_under_age_of_consent", true)

val request = AdRequest.Builder()
        .addNetworkExtrasBundle(AdMobAdapter::class.java, extras)
        .build()

The tags to enable the Child-directed setting and tag_for_under_age_of_consent should not both simultaneously be set to true. If they are, the child-directed setting takes precedence.

Ad content filtering

Apps can set a maximum ad content rating for their ad requests using the max_ad_content_rating network extra. AdMob ads returned for these requests have a content rating at or below that level. The possible values for this network extra are based on digital content label classifications, and should be one of the following strings:

  • G
  • PG
  • T
  • MA

The following code configures an AdRequest object to specify that ad content returned should correspond to a digital content label designation no higher than G:

Java

Bundle extras = new Bundle();
extras.putString("max_ad_content_rating", "G");

AdRequest request = new AdRequest.Builder()
        .addNetworkExtrasBundle(AdMobAdapter.class, extras)
        .build();

Kotlin

val extras = Bundle()

extras.putString("max_ad_content_rating", "G")

val request = AdRequest.Builder()
        .addNetworkExtrasBundle(AdMobAdapter::class.java, extras)
        .build()

Load an ad with targeting

Once your request targeting information is set, call loadAd() on the AdView with your AdRequest instance.

Java

AdRequest request = new AdRequest.Builder()
        .tagForChildDirectedTreatment(true)
        .build();
adView.loadAd(request);

Kotlin

val request = AdRequest.Builder()
        .tagForChildDirectedTreatment(true)
        .build()
adView.loadAd(request)

See the AdMob Ad Targeting example for an implementation of ad targeting in the Android API Demo app.

Send feedback about...

Google AdMob > Mobile Ads SDK > Android
Google AdMob > Mobile Ads SDK > Android
Need help? Visit our support page.