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.

Gender

If your app already knows user's gender, it can be supplied in the ad request for targeting purposes. This information is also forwarded to ad network mediation adapters.

Swift

let request = GADRequest()
request.gender = .male

Objective-C

GADRequest *request = [GADRequest request];
request.gender = kGADGenderMale;

See the GADGender enum in GADRequest.h for a full list of gender options.

Birthday

If your app already knows user's birthday, it can be supplied in the ad request for targeting purposes. This information is also forwarded to ad network mediation adapters.

Swift

let request = GADRequest()
var components = DateComponents()
components.month = 3
components.day = 13
components.year = 1976
request.birthday = Calendar.current.date(from: components)

Objective-C

GADRequest *request = [GADRequest request];
NSDateComponents *components = [[NSDateComponents alloc] init];
components.month = 3;
components.day = 13;
components.year = 1976;
request.birthday = [[NSCalendar currentCalendar] dateFromComponents:components];

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.

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.gender = .male
var components = DateComponents()
components.month = 3
components.day = 13
components.year = 1976
request.birthday = Calendar.current.date(from: components)
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.gender = kGADGenderMale;
NSDateComponents *components = [[NSDateComponents alloc] init];
components.month = 3;
components.day = 13;
components.year = 1976;
request.birthday = [[NSCalendar currentCalendar] dateFromComponents:components];
[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 のサポートページをご覧ください。