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 Swift or Objective-C.

Download API Demo


Complete the Get Started guide.


GADRequestConfiguration is an object that collects targeting information to be applied globally through the GADMobileAds shared instance. It can be accessed with the following code:


let requestConfiguration = GADMobileAds.sharedInstance().requestConfiguration


GADRequestConfiguration requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;

Child-directed setting

For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called tagForChildDirectedTreatment.

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:

  • Set tagForChildDirectedTreatment to YES to indicates that you want your content treated as child-directed for purposes of COPPA. This will prevent the transmission of the Advertising Identifier, IDFA.
  • Set tagForChildDirectedTreatment to NO 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.

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


GADMobileAds.sharedInstance().requestConfiguration.tag(forChildDirectedTreatment: true)


[GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment:YES];

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.

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 the European Union’s 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 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 calling the tagForUnderAgeOfConsent method on the GADMobileAds.requestConfiguration object and passing in YES.

  • Set tagForUnderAgeOfConsent to YES or true to indicate that you want ad requests to be handled in a manner suitable for users under the age of consent. This will also prevent the transmission of the Advertising Identifier, IDFA.
  • Not setting tagForUnderAgeOfConsent indicates 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:




[GADMobileAds.sharedInstance.requestConfiguration tagForUnderAgeOfConsent:YES];

The tags to enable the child-directed setting and tagForUnderAgeOfConsent 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 all ad requests using the maxAdContentRating property of GADRequestConfiguration. This setting applies to all future ad requests for the remainder of the session. The possible values for this property are based on digital content label classifications, and should be one of the following constants:

  • GADMaxAdContentRatingGeneral
  • GADMaxAdContentRatingParentalGuidance
  • GADMaxAdContentRatingTeen
  • GADMaxAdContentRatingMatureAudience

The following code configures all ad requests to specify that ad content returned should correspond to a Digital Content Label designation no higher than GADMaxAdContentRatingGeneral.


GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =


GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =


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

Content URL

When requesting an ad, apps can 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, you can pass this URL to target relevant keywords:


let request = GAMRequest()
request.contentURL = ""


GAMRequest *request = [GAMRequest request];
request.contentURL = @"";

Custom targeting

Once you've configured key-value pairs in the Ad Manager UI, set custom targeting with the desired key values in an ad request. Line items that target those key values are then eligible to serve for that ad request. To target multiple values for one key, enter values as a comma-separated string.


let request = GAMRequest()
request.customTargeting = ["gender" : "male", "section" : "health,fitness"];


GAMRequest *request = [GAMRequest request];
request.customTargeting = @{@"gender" : @"male", @"section" : @"health,fitness"};

Brand safety (Beta)

Apps that display dynamic content intended for varying audiences can provide a short list of URLs through the neighboringContentURLs property. Neighboring content URLs differ from the contentURL property in that they are only used for brand safety.

Suppose your app displays content from four 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 =
    ["", "",
    "", ""]


GAMRequest *request = [GAMRequest request];
request.neighboringContentURLs =
    @[@"", @"",
    @"", @""];

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:

Swift Objective-C


What targeting gets used when an ad automatically refreshes?
On ad refresh, the previously specified GAMRequest object is used for targeting again. To set new targeting, explicitly call loadRequest on GAMBannerView with a new GAMRequest object.
How do I pass extra targeting parameters to mediation networks?
See Mediation to find out how to send targeting to mediation networks.