Stay organized with collections Save and categorize content based on your preferences.
This guide explains how to provide targeting information to the Google Mobile Ads SDK.
For a working example, download the Android API Demo app.
PrerequisiteRequestConfiguration
collects targeting information applied globally to every ad request. For available targeting tags, refer to the RequestConfiguration.Builder
documentation.
To update the request configuration, obtain a builder from the existing configuration, perform any desired updates, and set it as follows:
Kotlinval requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
To ensure that all ad requests apply the request configuration changes, set the request configuration before you Initialize the Mobile Ads SDK.
Child-directed settingFor 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.
You can apply the child-directed setting through setTagForChildDirectedTreatment()
:
Call setTagForChildDirectedTreatment
with TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
to indicate that you want your content treated as child-directed for purposes of COPPA. This prevents the transmission of the Android advertising identifier (AAID).
Call setTagForChildDirectedTreatment
with TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
to indicate that you don't want your content treated as child-directed for purposes of COPPA.
Call setTagForChildDirectedTreatment
with TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
if you don't want 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:
Kotlinval requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
Note: Apps in the Designed For Families Program as Primarily child-directed apps and users signed into Google accounts managed with Family Link automatically have all content treated as child-directed for all ad requests. Users under the age of consent
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. Review European Union guidance and consult with your own legal counsel. Note 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 is included in the ad request. This parameter disables personalized advertising, including remarketing, for all ad requests. It also disables requests to third-party ad vendors, such as ad measurement pixels and third-party ad servers.
Like child-directed settings, there is a method in RequestConfiguration.Builder
for setting the TFUA parameter: setTagForUnderAgeOfConsent()
, with the following options.
Call setTagForUnderAgeOfConsent()
with TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE
to indicate that you want the ad request to receive treatment for users in the European Economic Area (EEA) under the age of consent. This also prevents the transmission of the Android advertising identifier (AAID).
Call setTagForUnderAgeOfConsent()
with TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE
to indicate that you want the ad request to not receive treatment for users in the European Economic Area (EEA) under the age of consent.
Call setTagForUnderAgeOfConsent()
with TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED
to indicate that you have not specified whether the ad request should receive treatment for users in the European Economic Area (EEA) under the age of consent.
The following example indicates that you want TFUA included in your ad requests:
Kotlinval requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
The tags to enable the Child-directed setting and setTagForUnderAgeOfConsent()
should not both simultaneously be set to true
. If they are, the child-directed setting takes precedence.
To comply with Google Play's Inappropriate Ads Policy that includes associated offers within an ad, all ads and their associated offers shown within your app must be appropriate for the content rating of your app, even if the content by itself is otherwise compliant with Google Play's policies.
Tools like maximum ad content rating can help you have more control over the content of the ads shown to your users. You can set a maximum content rating to help compliance with platform policies.
Apps can set a maximum ad content rating for their ad requests using the setMaxAdContentRating
method. AdMob ads returned when this is configured have a content rating at or below that level. The possible values for this network extra are based on digital content label classifications, and must be one of the following strings:
MAX_AD_CONTENT_RATING_G
MAX_AD_CONTENT_RATING_PG
MAX_AD_CONTENT_RATING_T
MAX_AD_CONTENT_RATING_MA
The following code configures an RequestConfiguration
object to specify that ad content returned should correspond to a digital content label designation no higher than G
:
val requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
Learn more about:
The Publisher Privacy Treatment (PPT) API is an optional tool that lets apps indicate whether to turn off ads personalization for all ad requests using the setPublisherPrivacyPersonalizationState()
method. When using this feature, a publisher privacy treatment (PPT) parameter is included in all future ad requests for the remainder of the session.
By default, ad requests to Google are served personalized ads. The following code turns off ads personalization for all ad requests:
Kotlinval requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setPublisherPrivacyPersonalizationState(PublisherPrivacyPersonalizationState.DISABLED)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
.toBuilder()
.setPublisherPrivacyPersonalizationState(PublisherPrivacyPersonalizationState.DISABLED)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
Note: For ad requests with multiple user privacy signals, the most restrictive signal will take precedence. See the Publisher Privacy Treatment API documentation for specific examples. Ad request
The AdRequest
object collects targeting information to be sent with an ad request.
Refer to the Ad Targeting example for an implementation of ad targeting in the Android API Demo app.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-05-10 UTC."],[[["This guide details how to provide targeting information to the Google Mobile Ads SDK, enabling control over ad content and user privacy."],["You can specify if your app's content is child-directed, impacting ad selection and the transmission of the Android advertising identifier (AAID)."],["For users under the age of consent in the EEA, you can disable personalized advertising and third-party ad vendor requests to comply with GDPR."],["Ad content filtering allows you to set a maximum content rating for ads shown in your app, ensuring compliance with platform policies."],["The Publisher Privacy Treatment (PPT) API gives you the option to turn off ad personalization for all ad requests during a session."]]],["This guide details configuring the Google Mobile Ads SDK for ad targeting. Key actions include using `RequestConfiguration` to set global targeting, applying child-directed treatment settings via `setTagForChildDirectedTreatment`, and managing users under the age of consent in the EEA with `setTagForUnderAgeOfConsent`. It also covers setting a maximum ad content rating using `setMaxAdContentRating` and disabling ad personalization for all requests via `setPublisherPrivacyPersonalizationState`. All settings should be applied before initializing the Mobile Ads SDK.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3