Targeting

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.

Download API Demo

Prerequisites

Complete the Get Started guide.

GADRequest

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

Location

If a user has granted your app location permissions, location data is automatically passed 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.

After getting the user's location, you can specify location-targeting information in the GADRequest as follows:

Swift

let request = GADRequest()
if let currentLocation = locationManager.location {
  request.setLocationWithLatitude(CGFloat(currentLocation.coordinate.latitude),
      longitude: CGFloat(currentLocation.coordinate.longitude),
      accuracy: CGFloat(currentLocation.horizontalAccuracy))
}

Objective-C

GADRequest *request = [GADRequest request];
CLLocation *currentLocation = locationManager.location;
if (currentLocation) {
  [request setLocationWithLatitude:currentLocation.coordinate.latitude
                         longitude:currentLocation.coordinate.longitude
                          accuracy:currentLocation.horizontalAccuracy];
}

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

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.
  • 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.

Swift

let request = GADRequest()
request.tag(forChildDirectedTreatment: true)

Objective-C

GADRequest *request = [GADRequest request];
[request 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.

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 will 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.

Swift

let request = GADRequest();
let extras = GADExtras();
extras.additionalParameters = ["max_ad_content_rating": "G"];
request.register(extras)

Objective-C

GADRequest *request = [GADRequest request];
GADExtras *extras = [[GADExtras alloc] init];
extras.additionalParameters = @{@"max_ad_content_rating": @"G"};
[request registerAdNetworkExtras:extras];

Content URL

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 serves blog articles and is requesting an ad while showing content from the article http://googleadsdeveloper.blogspot.com/2016/03/rewarded-video-support-for-admob.html, then you can pass this URL to target relevant keywords:

Swift

let request = GADRequest()
request.contentURL = "http://googleadsdeveloper.blogspot.com/2016/03/rewarded-video-support-for-admob.html"

Objective-C

GADRequest *request = [GADRequest request];
request.contentURL = @"http://googleadsdeveloper.blogspot.com/2016/03/rewarded-video-support-for-admob.html";

Load an ad with targeting

Once all of your request targeting information is set, call loadRequest on GADBannerView with your GADRequest instance.

Swift

let request = GADRequest()
request.tag(forChildDirectedTreatment: true)
request.contentURL = "http://googleadsdeveloper.blogspot.com/2016/03/rewarded-video-support-for-admob.html"
adView.loadRequest(request)

Objective-C

GADRequest *request = [GADRequest request];
[request tagForChildDirectedTreatment:YES];
request.contentURL = @"http://googleadsdeveloper.blogspot.com/2016/03/rewarded-video-support-for-admob.html";
[self.adView loadRequest:request];

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

Objective-C Swift

FAQ

Can I release my app with request.testDevices?
Yes. Test ads are only shown on specific devices that you specify, so all of your users will still receive production ads.
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.

フィードバックを送信...

Google Mobile Ads SDK for iOS
Google Mobile Ads SDK for iOS
ご不明な点がありましたら、Google のサポートページをご覧ください。