ターゲティング

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

Prerequisites

Complete the Get Started guide.

GADRequestConfiguration

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:

Swift

let requestConfiguration = GADMobileAds.sharedInstance().requestConfiguration

Objective-C

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, Google takes steps to disable IBA and remarketing ads on that ad request. The setting options are as follows:

  • Set tagForChildDirectedTreatment to true to indicate that you want your content treated as child-directed for purposes of COPPA. This prevents the transmission of the Advertising Identifier, IDFA.
  • Set tagForChildDirectedTreatment to false to indicate that you don't want your content treated as child-directed for purposes of COPPA.
  • Don't set tagForChildDirectedTreatment if you don't want 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:

Swift

GADMobileAds.sharedInstance().requestConfiguration.tagForChildDirectedTreatment = true

Objective-C

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 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 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 setting the tagForUnderAgeOfConsent property on the GADMobileAds.requestConfiguration object and passing in true.

  • Set tagForUnderAgeOfConsent to true to indicate that you want ad requests to be handled in a manner suitable for users under the age of consent. This also prevents 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:

Swift

GADMobileAds.sharedInstance().requestConfiguration.tagForUnderAgeOfConsent = true

Objective-C

GADMobileAds.sharedInstance.requestConfiguration.tagForUnderAgeOfConsent = @YES;

The tags to enable the child-directed setting and tagForUnderAgeOfConsent shouldn't 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.

Swift

GADMobileAds.sharedInstance().requestConfiguration.maxAdContentRating =
    GADMaxAdContentRatingGeneral

Objective-C

GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
    GADMaxAdContentRatingGeneral;

Publisher Privacy Treatment (Beta)

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 publisherPrivacyPersonalizationState property of GADRequestConfiguration. 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:

Swift

GADMobileAds.sharedInstance().requestConfiguration.publisherPrivacyPersonalizationState =
    .disabled

Objective-C

GADMobileAds.sharedInstance.requestConfiguration.publisherPrivacyPersonalizationState =
    GADPublisherPrivacyPersonalizationStateDisabled;

GADRequest

The GADRequest 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 https://www.example.com, you can pass this URL to target relevant keywords:

Swift

let request = GADRequest()
request.contentURL = "https://www.example.com"

Objective-C

GADRequest *request = [GADRequest request];
request.contentURL = @"https://www.example.com";

FAQ

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