This guide explains how to provide targeting information to an ad request.
To see ad targeting in action, download the iOS API Demo app in Objective-C or Swift.
Complete the Get Started guide.
It can be accessed via the following piece of code:
let requestConfiguration = GADMobileAds.sharedInstance().requestConfiguration
GADRequestConfiguration requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
For purposes of the Children's Online Privacy Protection Act
there is a setting called
As an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request. When 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 options are as follows:
YESto indicates that you want your content treated as child-directed for purposes of COPPA.
NOto indicate that you don't want your content treated as child-directed for purposes of COPPA.
Do not set
tagForChildDirectedTreatmentif you do not wish to indicate how you would like your content treated with respect to COPPA.
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.
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. 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 all future ad requests. 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
tagForUnderAgeOfConsent method on the
GADMobileAds.requestConfiguration object and passing in
trueto indicate that you want ad requests to be handled in a manner suitable for users under the age of consent.
- Not setting
tagForUnderAgeOfConsentindicates that you don't want ad requests 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:
The tags to enable the child-directed setting
tagForUnderAgeOfConsent should not both simultaneously be set to
If they are, the child-directed setting takes precedence.
GAMRequest object collects targeting information to be sent with an ad
When requesting an ad, apps may pass the URL of the content they are serving. This enables keyword targeting to match the ad with the content.
For example, if your app is requesting an ad while showing content from
https://www.example.com, you can pass this URL to target relevant keywords:
let request = GAMRequest() request.contentURL = "https://www.example.com"
GAMRequest *request = [GAMRequest request]; request.contentURL = @"https://www.example.com";
Applications that display dynamic content intended for varying audiences
are able to provide a short list of URLs via the
property. Neighboring content URLs differ from the
contentURL property in that
they are only used for brand safety.
Suppose your app displays content from 4 urls in a feed that also contains ads. You can request ads which have a similar content rating to those URLs, by passing them like so:
let request = GAMRequest() request.neighboringContentURLs = ["https://www.example1.com", "https://www.example2.com", "https://www.example3.com", "https://www.example4.com"]
GAMRequest *request = [GAMRequest request]; request.neighboringContentURLs = @[@"https://www.example1.com", @"https://www.example2.com", @"https://www.example3.com", @"https://www.example4.com"];
Publisher provided identifiers
You can set a publisher provided identifier (PPID) for use in frequency capping, audience segmentation and targeting, sequential ad rotation, and other audience-based ad delivery controls across devices.
Setting the PPID is done through GAMRequest:
let request = GAMRequest() request.publisherProvidedID = "AB123456789"
GAMRequest *request = [GAMRequest request]; request.publisherProvidedID = @"AB123456789";
See the Ad Manager PPID example for an implementation of publisher provided identifiers (PPID) in the iOS API Demo app.
- What targeting gets used when an ad automatically refreshes?
- On ad refresh, the previously specified
GAMRequestobject is used for targeting again. To set new targeting, explicitly call
GAMBannerViewwith a new
- How do I pass extra targeting parameters to mediation networks?
- See Mediation to find out how to send targeting to mediation networks.