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.
Set the request configuration
The RequestConfiguration object collects targeting
information applied globally to every ad request.
To apply targeting settings from your first ad request, set the
requestConfiguration property when you call the
initialize method:
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, call the
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:
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 property on
RequestConfiguration.
The following example indicates that ad requests should receive child age treatment:
To indicate teen or an unspecified age treatment, replace the
AgeRestrictedTreatment.CHILD setting with the
following:
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.
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 property on the
RequestConfiguration 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,
and must be one of the following constants:
The following example configures a RequestConfiguration
object to specify that ad content returned should correspond to a digital
content label designation no higher than the G constant:
For details, see the following:
Optional: Set the PPT API (Beta)
The
Publisher Privacy Treatment
(PPT) API lets you indicate whether to turn off ads personalization for all ad
requests using the
publisherPrivacyPersonalizationState property on the
RequestConfiguration 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:
Set the AdRequest object
The AdRequest 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 property.
The following example sets an extra parameter key of collapsible with
a value of bottom:
Provide a content URL
To provide a content URL for content-targeted ads and brand safety, add the
contentUrl property:
The content URL must be up to 512 characters.