<br />

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](https://github.com/googleads/googleads-mobile-ios-examples/releases/latest)

## Prerequisites

Before you continue, [set up Google Mobile Ads SDK](https://developers.google.com/admob/ios/quick-start.md.txt).

## GADRequestConfiguration

[`GADRequestConfiguration`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt)
is an object that collects targeting information to be applied globally through
the
[`GADMobileAds`](https://developers.google.com/admob/ios/api/reference/Classes/GADMobileAds.md.txt#requestconfiguration)
shared instance. It can be accessed with the following code:

### Swift

```swift
let requestConfiguration = MobileAds.shared.requestConfiguration
```

### Objective-C

```objective-c
GADRequestConfiguration requestConfiguration = GADMobileAds.sharedInstance.requestConfiguration;
```

To ensure that all ad requests apply the request configuration changes, set
the request configuration before you
[Initialize Google Mobile Ads SDK](https://developers.google.com/admob/ios/quick-start.md.txt#initialize_the_mobile_ads_sdk).

### Set the age treatment

To help you manage your compliance with applicable privacy regulations related
to children and teens, Google Mobile Ads SDK provides an age treatment setting. The
age treatment setting lets you indicate whether Google Mobile Ads SDK should apply
specific ad serving protections for children, teens, or an unspecified age.

You can set age treatment with the `ageRestrictedTreatment` property on
[`GADRequestConfiguration`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt).

The following example indicates that ad requests should receive child age
treatment:

### Swift

```swift
// Indicates that ad requests should have child age treatment.
MobileAds.shared.requestConfiguration.ageRestrictedTreatment = .child
```

To indicate teen or unspecified age treatment, replace the `.child` setting
with the following:

- `.teen`
- `.unspecified`

### Objective-C

```objective-c
// Indicates that ad requests should have child age treatment.
GADMobileAds.sharedInstance.requestConfiguration.ageRestrictedTreatment =
    GADAgeRestrictedTreatmentChild;
```

To indicate teen or unspecified age treatment, replace the
`GADAgeRestrictedTreatmentChild` setting with the following:

- `GADAgeRestrictedTreatmentTeen`
- `GADAgeRestrictedTreatmentUnspecified`

When using the setting,
Google Mobile Ads SDK includes a `tfat` parameter in ad requests. Consult your legal
counsel to determine the applicable age treatment for your users based on your
legal and regulatory obligations. For more information, see
[Tag an ad request from an app for age restricted treatment](https://support.google.com/admob/answer/6219315).

#### Migrate to age treatment from TFCD and TFUA

The age treatment setting [replaces the deprecated](https://developers.google.com/admob/ios/rel-notes.md.txt#13.3.0)
`tagForChildDirectedTreatment` (TFCD) and `tagForUnderAgeOfConsent` (TFUA)
properties.

The following table shows the `tagForChildDirectedTreatment` and
`tagForUnderAgeOfConsent` settings and their age treatment equivalents:

### TFCD

| `tagForChildDirectedTreatment` | Age treatment |
|---|---|
| `tagForChildDirectedTreatment = true` | `GADAgeRestrictedTreatmentChild` |
| `tagForChildDirectedTreatment = false` | `GADAgeRestrictedTreatmentUnspecified` |
| No value assigned to `tagForChildDirectedTreatment` | `GADAgeRestrictedTreatmentUnspecified` |
| No equivalent | `GADAgeRestrictedTreatmentTeen` |

### TFUA

| `tagForUnderAgeOfConsent` | Age treatment |
|---|---|
| `tagForUnderAgeOfConsent = true` | `GADAgeRestrictedTreatmentChild` |
| `tagForUnderAgeOfConsent = false` | `GADAgeRestrictedTreatmentUnspecified` |
| No value assigned to `tagForUnderAgeOfConsent` | `GADAgeRestrictedTreatmentUnspecified` |
| No equivalent | `GADAgeRestrictedTreatmentTeen` |

#### Understand age treatment interactions with TFCD and TFUA

If you set age treatment setting and TFCD or TFUA settings, Google applies the
most conservative treatment.

> [!NOTE]
> **Note:** Users signed into Google Accounts managed with [Family
> Link](https://families.google.com/familylink/) automatically have all content treated as child-directed for all ad requests.

#### Forward age treatment with AdMob Mediation

If you [set the age treatment](https://developers.google.com/admob/ios/targeting.md.txt#set_the_age_treatment) using Google Mobile Ads SDK,
mediation adapters forward the age treatment signal to mediated third-party
SDKs.

The following table lists the mediation adapter versions that support forwarding
the age-restricted treatment signal to the mediated third-party SDK:

| Mediation adapter name | Minimum supported version |
|---|---|
| [AppLovin](https://developers.google.com/admob/ios/mediation/applovin.md.txt) | 13.6.3.0 |
| [BidMachine](https://developers.google.com/admob/ios/mediation/bidmachine.md.txt) | 3.6.1.1 |
| [Bigo](https://developers.google.com/admob/ios/mediation/bigo.md.txt) | 5.2.1.0 |
| [Chartboost](https://developers.google.com/admob/ios/mediation/chartboost.md.txt) | 9.12.0.1 |
| [DTExchange (Fyber)](https://developers.google.com/admob/ios/mediation/dt-exchange.md.txt) | 8.4.7.1 |
| [i-mobile](https://developers.google.com/admob/ios/mediation/imobile.md.txt) | 2.3.4.7 |
| [InMobi](https://developers.google.com/admob/ios/mediation/inmobi.md.txt) | 11.2.0.1 |
| [IronSource](https://developers.google.com/admob/ios/mediation/ironsource.md.txt) | 9.4.1.0.1 |
| [Liftoff Monetize (Vungle)](https://developers.google.com/admob/ios/mediation/liftoff-monetize.md.txt) | 7.7.2.1 |
| [LY Ads (Line Ads)](https://developers.google.com/admob/ios/mediation/line.md.txt) | 3.0.1.1 |
| [maio](https://developers.google.com/admob/ios/mediation/maio.md.txt) | 2.2.1.2 |
| [Meta (Facebook)](https://developers.google.com/admob/ios/mediation/meta.md.txt) | 6.21.1.1 |
| [Mintegral](https://developers.google.com/admob/ios/mediation/mintegral.md.txt) | 8.1.3.1 |
| [Moloco](https://developers.google.com/admob/ios/mediation/moloco.md.txt) | 4.6.1.1 |
| [MyTarget](https://developers.google.com/admob/ios/mediation/mytarget.md.txt) | 5.43.0.0 |
| [Pangle](https://developers.google.com/admob/ios/mediation/pangle.md.txt) | 7.9.1.1.1 |
| [PubMatic](https://developers.google.com/admob/ios/mediation/pubmatic.md.txt) | 5.1.0.1 |
| [Verve](https://developers.google.com/admob/ios/mediation/verve.md.txt) | 3.8.1.1 |

### Child-directed setting

> [!WARNING]
> **Warning:** The `tagForChildDirectedTreatment` property is deprecated. Instead, [set the `ageRestrictedTreatment`](https://developers.google.com/admob/ios/targeting.md.txt#set_the_age_treatment) property.

For purposes of the [Children's Online Privacy Protection Act
(COPPA)](https://www.ftc.gov/business-guidance/privacy-security/childrens-privacy),
there is a setting called
[`tagForChildDirectedTreatment`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt#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

```swift
MobileAds.shared.requestConfiguration.tagForChildDirectedTreatment = true
```

### Objective-C

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

### Users under the age of consent

> [!WARNING]
> **Warning:** The `tagForUnderAgeOfConsent` property is deprecated. Instead, [set the
> `ageRestrictedTreatment`](https://developers.google.com/admob/ios/targeting#set_the_age_treatment) property.


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)](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32016R0679). You may have other legal
obligations under GDPR. Review European Union guidance and consult with
your own legal counsel. Google's tools are designed to facilitate
compliance and don't relieve any particular publisher of its obligations under
the law.


[Learn more about how the GDPR affects
publishers](https://support.google.com/admob/answer/7666366).


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 Google Mobile Ads SDK by
setting the
[`tagForUnderAgeOfConsent`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt#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

```swift
MobileAds.shared.requestConfiguration.tagForUnderAgeOfConsent = true
```

### Objective-C

```objective-c
GADMobileAds.sharedInstance.requestConfiguration.tagForUnderAgeOfConsent = @YES;
```

The tags to enable the [child-directed setting](https://developers.google.com/admob/ios/targeting.md.txt#child-directed_setting)
and `tagForUnderAgeOfConsent` shouldn't both simultaneously be set to `true`.
If they are, the child-directed setting takes precedence.

> [!IMPORTANT]
> **Key Point:** This `tagForUnderAgeOfConsent` parameter is *not* forwarded to mediation adapters for third-party ad sources. It's your responsibility to ensure that each third-party ad network in your app serves ads that are appropriate for users under the age of consent per GDPR.

### 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](https://support.google.com/admob/answer/7562142), 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`.

> [!IMPORTANT]
> **Key Point:** Content rating filter settings specified through the SDK override any settings configured using the AdMob UI.

### Swift

```swift
MobileAds.shared.requestConfiguration.maxAdContentRating =
  GADMaxAdContentRating.general
```

### Objective-C

```objective-c
GADMobileAds.sharedInstance.requestConfiguration.maxAdContentRating =
    GADMaxAdContentRatingGeneral;
```

### Publisher Privacy Treatment (Beta)

The

[Publisher Privacy Treatment](https://support.google.com/admob/answer/14323214)

(PPT) API is an optional tool that lets apps indicate whether to turn off ads
personalization for all ad requests using the
[`publisherPrivacyPersonalizationState`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt#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

```swift
MobileAds.shared.requestConfiguration.publisherPrivacyPersonalizationState =
    .disabled
```

### Objective-C

```objective-c
GADMobileAds.sharedInstance.requestConfiguration.publisherPrivacyPersonalizationState =
    GADPublisherPrivacyPersonalizationStateDisabled;
```

> [!NOTE]
> **Note:** For ad requests with multiple user privacy signals, the most restrictive signal will take precedence. See the [Publisher Privacy Treatment API](https://support.google.com/admob/answer/14323214) documentation for specific examples.

### Collect coarse location

Google Mobile Ads SDK can collect coarse location to target ads based on the device
location. If a user grants location permission in your app,
Google Mobile Ads SDK collects coarse location.

Starting in Google Mobile Ads SDK version 13.12.0, coarse location collection is
enabled by default. You can disable coarse location collection using the
[`coarseLocationCollectionEnabled`](https://developers.google.com/admob/ios/api/reference/Classes/GADRequestConfiguration.md.txt#coarselocationcollectionenabled)
property.

The following example disables coarse location collection:

### Swift

```swift
// Disables automatic coarse location collection by the SDK.
MobileAds.shared.requestConfiguration.coarseLocationCollectionEnabled = false
```

### Objective-C

```objective-c
// Disables automatic coarse location collection by the SDK.
GADMobileAds.sharedInstance.requestConfiguration.coarseLocationCollectionEnabled = NO;
```

## GADRequest

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

### Add network extras

Network extras are extra details sent with an ad request that are specific to
a single ad source.

The following code snippet sets an extra parameter key of `collapsible` with
a value of `bottom` to Google:

### Swift

```swift
let request = Request()
let extras = Extras()
extras.additionalParameters = ["collapsible": "bottom"]
request.register(extras)
adLoader?.load(request)
```

### Objective-C

```objective-c
GADRequest *request = [GADRequest request];
GADExtras *extras = [[GADExtras alloc] init];
extras.additionalParameters = @{@"collapsible": @"bottom"};
[request registerAdNetworkExtras:extras];
[self.adLoader loadRequest: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

```swift
let request = Request()
request.contentURL = "https://www.example.com"
```

### Objective-C

```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](https://developers.google.com/admob/ios/mediation.md.txt) to find out how to send targeting to
    mediation networks.