<br />

Targeting lets you provide contextual and audience information to
Google Mobile Ads SDK for React Native to serve relevant ads to your users.

You can configure targeting at these levels:

- **Global request configuration**: Apply settings across all ad requests in your app, including child and teen age treatments, maximum ad content ratings, publisher privacy treatments, and test device IDs.
- **Per-request targeting:** Customize individual ad requests using ad request objects, including content URLs and network extras.

This guide explains how to provide targeting information to Google Mobile Ads SDK for React Native.

## Prerequisites

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

## Set the request configuration

The [`RequestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt) object collects targeting
information applied globally to every ad request.

To apply targeting settings from your first ad request, set the
[`requestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/InitializationConfig.md.txt#InitializationConfig.requestConfiguration) property when you call the
[`initialize`](https://developers.google.com/admob/react-native/reference.md.txt#initialize) method:

```typescript
const requestConfiguration: RequestConfiguration = {
  maxAdContentRating: MaxAdContentRating.G,
  ageRestrictedTreatment: AgeRestrictedTreatment.CHILD,
  publisherPrivacyPersonalizationState:
    PublisherPrivacyPersonalizationState.DISABLED,
  testDeviceIds: ["TEST_DEVICE_HASHED_ID"],
};

initialize({requestConfiguration}, (_status: InitializationStatus) => {
  // SDK initialization is complete.
});
```

Replace `TEST_DEVICE_HASHED_ID` with a
hashed test device ID. This ID specifies a device that should receive test ads.

To update your targeting settings after you
[initialize Google Mobile Ads SDK for React Native](https://developers.google.com/admob/react-native/quick-start.md.txt#initialize-the-mobile-ads-sdk), call the
[`setRequestConfiguration`](https://developers.google.com/admob/react-native/reference.md.txt#setRequestConfiguration) method. The
`setRequestConfiguration` method replaces an existing configuration and takes
effect on subsequent ad requests.

The following example revises a `RequestConfiguration` object with updated
targeting settings and applies the settings to ad requests:

```typescript
const requestConfiguration: RequestConfiguration = {
  ...getRequestConfiguration(),
  maxAdContentRating: MaxAdContentRating.PG,
  ageRestrictedTreatment: AgeRestrictedTreatment.TEEN,
};

setRequestConfiguration(requestConfiguration);
```

### Set the age treatment

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

You can set age treatment with the
[`ageRestrictedTreatment`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt#RequestConfiguration.ageRestrictedTreatment) property on
[`RequestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt).

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

```typescript
const requestConfiguration: RequestConfiguration = {
  // Indicate that ad requests should have child age treatment.
  ageRestrictedTreatment: AgeRestrictedTreatment.CHILD,
};

setRequestConfiguration(requestConfiguration);
```

To indicate teen or an unspecified age treatment, replace the
[`AgeRestrictedTreatment.CHILD`](https://developers.google.com/admob/react-native/reference.md.txt#AgeRestrictedTreatment) setting with the
following:

- [`AgeRestrictedTreatment.TEEN`](https://developers.google.com/admob/react-native/reference.md.txt#AgeRestrictedTreatment)
- [`AgeRestrictedTreatment.UNSPECIFIED`](https://developers.google.com/admob/react-native/reference.md.txt#AgeRestrictedTreatment)

When you use this setting, Google Mobile Ads SDK for React Native 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).

### Filter ad content

Maximum ad content rating lets you control the content of the ads shown to your
users. You can set a maximum content rating to help compliance with platform
policies.

You can set a maximum ad content rating for ad requests in your app using the
[`maxAdContentRating`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt#RequestConfiguration.maxAdContentRating) property on the
[`RequestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt) object.
After you configure this setting, ads returned have a content rating at or
lower than that rating. The possible values for this setting are based on
[digital content label classifications](https://support.google.com/admob/answer/7562142),
and must be one of the following constants:

- [`MaxAdContentRating.G`](https://developers.google.com/admob/react-native/reference.md.txt#MaxAdContentRating)
- [`MaxAdContentRating.PG`](https://developers.google.com/admob/react-native/reference.md.txt#MaxAdContentRating)
- [`MaxAdContentRating.T`](https://developers.google.com/admob/react-native/reference.md.txt#MaxAdContentRating)
- [`MaxAdContentRating.MA`](https://developers.google.com/admob/react-native/reference.md.txt#MaxAdContentRating)

The following example configures a [`RequestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt)
object to specify that ad content returned should correspond to a digital
content label designation no higher than the `G` constant:

```typescript
const requestConfiguration: RequestConfiguration = {
  maxAdContentRating: MaxAdContentRating.G,
};

setRequestConfiguration(requestConfiguration);
```

For details, see the following:

- [Setting the maximum content rating for each ad
  request](https://support.google.com/admob/answer/10477886)

- [Setting the maximum ad content rating for an app or
  account](https://support.google.com/admob/answer/7562142)

> [!NOTE]
> **Note:** Content rating filter settings specified through Google Mobile Ads SDK for React Native override any settings configured using the AdMob UI.

### Optional: Set the PPT API (Beta)

The

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

(PPT) API lets you indicate whether to turn off ads personalization for all ad
requests using the
[`publisherPrivacyPersonalizationState`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt#RequestConfiguration.publisherPrivacyPersonalizationState) property on the
[`RequestConfiguration`](https://developers.google.com/admob/react-native/reference/interface/RequestConfiguration.md.txt) object. When you use this feature,
Google Mobile Ads SDK for React Native includes a publisher privacy treatment (PPT) parameter in all
ad requests for the remainder of the session.

By default, ad requests to Google are served personalized ads. The following
example turns off ads personalization for all ad requests:

```typescript
const requestConfiguration: RequestConfiguration = {
  publisherPrivacyPersonalizationState:
    PublisherPrivacyPersonalizationState.DISABLED,
};

setRequestConfiguration(requestConfiguration);
```

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

## Set the `AdRequest` object

The [`AdRequest`](https://developers.google.com/admob/react-native/reference/interface/AdRequest.md.txt) object collects targeting information sent
with an ad request.

Unlike global configuration set with the `setRequestConfiguration` method, the
`AdRequest` object
is passed to the `load` method of an ad format class, for example,
`InterstitialAd.load` for interstitial ads or `BannerAd.load`
for banner ads.

### Add network extras

To pass network-specific parameters to Google Mobile Ads SDK for React Native, such as parameters for
collapsible ads, use the
[`extras`](https://developers.google.com/admob/react-native/reference/interface/AdRequest.md.txt#AdRequest.extras) property.

> [!NOTE]
> **Note:** To pass custom parameters to third-party mediation ad network adapters, use the \[`mediationExtras`\]\[ref_ad_request_mediation_extras\] property.

The following example sets an extra parameter key of `collapsible` with
a value of `bottom`:

```typescript
const request: AdRequest = {
  adUnitId: AD_UNIT_ID,
  extras: {
    collapsible: 'bottom',
  },
};
```

### Provide a content URL

To provide a content URL for content-targeted ads and brand safety, add the
[`contentUrl`](https://developers.google.com/admob/react-native/reference/interface/AdRequest.md.txt#AdRequest.contentUrl) property:

```typescript
const request: AdRequest = {
  adUnitId: AD_UNIT_ID,
  contentUrl: 'https://www.example.com',
};
```

The content URL must be up to 512 characters.