> [!WARNING]
> **DEPRECATED:** The Google Mobile Ads C++ SDK is *deprecated* as of June 17, 2024 and should not be adopted in projects that don't already use it. It will enter *End-of-Maintenance (EoM)* on June 17, 2025. Note that versions of the SDK released before the EoM date will continue to function, but no further bug fixes or changes will be released after the EoM date.
>
> Instead of the Google Mobile Ads C++ SDK, consider using the
> [iOS](https://developers.google.com/admob/ios/quick-start.md.txt) and
> [Android](https://developers.google.com/admob/android/quick-start.md.txt) SDKs from AdMob.
> For support, reach out to the
> [contact us form](https://support.google.com/admob/contact/contact_us_gma_sdk).

<br />

This guide explains how to provide targeting information to an ad request.

## Prerequisites

- Complete [Get started](https://developers.google.com/admob/cpp/quick-start.md.txt).

## `RequestConfiguration`

`RequestConfiguration` is a struct that collects targeting information to be
applied globally via the `SetRequestConfiguration()` global function.

To update the request configuration, obtain a the current configuration first,
perform any desired updates, and set it as follows:

```c++
  firebase::gma::RequestConfiguration retrieved_configuration =
    firebase::gma::GetRequestConfiguration();

  // .. apply your changes, then:

  firebase::gma::SetRequestConfiguration(request_configuration);
```

### Child-directed setting

For purposes of the [Children's Online Privacy Protection Act
(COPPA)](https://business.ftc.gov/privacy-and-security/children%27s-privacy),
there is a setting called "tag for child-directed treatment". 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.

As an app developer, you can indicate whether you want Google to treat your
content as child-directed when you make an ad request. If 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 can be configured by assigning the
`tag_for_child_directed_treatment` member of `RequestConfiguration` struct to
one of the following enumerated values:

- Assign `RequestConfiguration::tag_for_child_directed_treatment` to `RequestConfiguration::kChildDirectedTreatmentTrue` to indicate that you want your content treated as child-directed for purposes of COPPA.
- Assign `RequestConfiguration::tag_for_child_directed_treatment` to `RequestConfiguration::kChildDirectedTreatmentFalse` to indicate that you don't want your content treated as child-directed for purposes of COPPA.
- Assign `RequestConfiguration::tag_for_child_directed_treatment` to `RequestConfiguration::kChildDirectedTreatmentUnspecified`if you don't want to indicate how you would like your content treated with respect to COPPA in ad requests.

The following example indicates that you want your content treated as
child-directed for purposes of COPPA:

```c++
  firebase::gma::RequestConfiguration request_configuration =
    firebase::gma::GetRequestConfiguration();

  request_configuration.tag_for_child_directed_treatment =
    firebase::RequestConfiguration::kChildDirectedTreatmentTrue;

  firebase::gma::SetRequestConfiguration(request_configuration);
```

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.

> [!NOTE]
> **Note:** Apps in the [Designed For Families
> Program](https://developer.android.com/distribute/google-play/families) as [Primarily
> child-directed apps](https://support.google.com/admob/answer/6223431) and 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.

### Users under the age of consent

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).
Note that you may have other legal obligations under GDPR. Please review the
European Union's guidance and consult with your own legal counsel. Please
remember 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](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 the ad request. This parameter disables
personalized advertising, including remarketing, for all ad requests. It also
disables requests to third-party ad vendors, such as ad measurement pixels and
third-party ad servers.

Like child-directed settings, there is a member in RequestConfiguration for
configuring the TFUA parameter: `tag_for_under_age_of_consent`, which may be
configured with the following enumerated values:

- Assign `RequestConfiguration::tag_for_under_age_of_consent` to `RequestConfiguration::kUnderAgeOfConsentTrue` to indicate that you want the ad request to receive treatment for users in the European Economic Area (EEA) under the age of consent.
- Assign `RequestConfiguration::tag_for_under_age_of_consent` to `RequestConfiguration::kUnderAgeOfConsentFalse` to indicate that you want the ad request to not receive treatment for users in the European Economic Area (EEA) under the age of consent.
- Assign `RequestConfiguration::tag_for_under_age_of_consent` to `RequestConfiguration::kUnderAgeOfConsentUnspecified` to indicate that you have not specified whether the ad request should receive treatment for users in the European Economic Area (EEA) under the age of consent.

The following example indicates that you want TFUA included in your ad requests:

```c++
  firebase::gma::RequestConfiguration request_configuration =
    firebase::gma::GetRequestConfiguration();

  request_configuration.tag_for_under_age_of_consent =
    firebase::RequestConfiguration::kUnderAgeOfConsentTrue;

  firebase::gma::SetRequestConfiguration(request_configuration);
```

The tags to enable the Child-directed setting and Users under the Age of Consent
should not 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 their ad requests via the
`RequestConfiguration::max_ad_content_rating field`. AdMob ads returned when
this is configured have a content rating at or below that level. The possible
values for this are based on digital content label classifications and must be
one of the following enumerated values:

- `RequestConfiguration::kMaxAdContentRatingG`
- `RequestConfiguration::kMaxAdContentRatingPG`
- `RequestConfiguration::kMaxAdContentRatingT`
- `RequestConfiguration::kMaxAdContentRatingMA`

The following code configures a `RequestConfiguration` struct to specify that ad
content returned should correspond to a digital content label designation no
higher than G:

```c++
  firebase::gma::RequestConfiguration request_configuration =
    firebase::gma::GetRequestConfiguration();

  request_configuration.max_ad_content_rating =
    firebase::RequestConfiguration::kMaxAdContentRatingG;

  firebase::gma::SetRequestConfiguration(request_configuration);
```

## `AdRequest`

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

### 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 is requesting an ad while showing content from
`https://www.example.com`, you can pass this URL to target relevant keywords:

```c++
  // AdRequest with content URL:
  firebase::admob::AdRequest ad_request(/*content_url=*/"https://www.example.com");

  // AdRequest without content URL:
  firebase::admob::AdRequest ad_request();
```