Google Ad Manager (GAM) publishers can use the Ad Manager specific components and request options exposed by this
library. Use your Ad Manager ad unit paths (for example /network-code/ad-unit) rather than AdMob
ca-app-pub-… unit IDs.
Complete consent and SDK initialization before requesting GAM inventory. See Consent & privacy basics.
For multi-format Ad Manager requests (one request, native or banner winner via
useMultiFormatAd / MultiFormatAdRequest; custom native is an opt-in on MultiFormatAdRequest
only, not useMultiFormatAd), see Preload pools and multi-format
recipes.
For Ad Manager custom native ad formats (custom assets read by name, custom click handling), see Custom native (Ad Manager).
You can display a Google Ad Manager banner ad unit. In this case, you have to import the GAMBannerAd component and use the sizes prop instead of the size prop:
import React from 'react';
import { GAMBannerAd, GAMBannerAdSize, TestIds } from 'react-native-google-mobile-ads';
const adUnitId = __DEV__ ? TestIds.GAM_BANNER : '/xxx/yyyy';
function App() {
return (
<GAMBannerAd
unitId={adUnitId}
sizes={[GAMBannerAdSize.FULL_BANNER, GAMBannerAdSize.FLUID]}
requestOptions={{
customTargeting: {
section: 'sports',
subscriber: 1,
},
categoryExclusions: ['airline'],
}}
onPaid={event => {
console.log('GAM banner revenue', event.value, event.currency);
}}
/>
);
}The sizes prop accepts several eligible sizes for the same request. FLUID is available only
through GAMBannerAdSize and expands or contracts its height to fit the returned creative. See the
banner size catalog.
useGAMInterstitialAd owns one Ad Manager interstitial with the same status lifecycle as the
other options-form hooks, and adds GAM app events through onAppEvent.
import { useEffect } from 'react';
import { Button } from 'react-native';
import { TestIds, useGAMInterstitialAd } from 'react-native-google-mobile-ads';
const adUnitId = __DEV__ ? TestIds.GAM_INTERSTITIAL : '/xxx/interstitial';
const requestOptions = {
customTargeting: {
section: 'sports',
interests: ['football', 'running'],
},
categoryExclusions: ['airline'],
};
export default function GAMInterstitialButton({ consentReady }: { consentReady: boolean }) {
const { status, show, revenue } = useGAMInterstitialAd({
adUnitId,
autoLoad: consentReady,
requestOptions,
onAppEvent: ({ name, data }) => {
console.log('GAM app event', name, data);
},
});
useEffect(() => {
if (revenue) {
console.log('GAM interstitial revenue', revenue.value, revenue.currency);
}
}, [revenue]);
return (
<Button title="Show GAM interstitial" disabled={status !== 'loaded'} onPress={() => show()} />
);
}onAppEventreceives{ name, data }for each Ad Manager app event the creative sends. It is not mirrored into hook state, and changing the callback does not recreate the ad. Set up the creative side as described in Google's Ad Manager app events guide.- The hook's
show()is press-safe: it absorbs both the synchronous throw and the rejection, soonPress={() => show()}needs no.catch. A press while the ad isn't showable is a silent no-op; a platform show failure reported by the ad'sERRORevent surfaces asstatus: 'error'witherrorset. - The hook does not preload the next ad after
closed; callload()when another impression is plausible.
For imperative create / load / show outside React, GAMInterstitialAd.createForAdRequest is still
available. Listen for GAMAdEventType.APP_EVENT, and handle show() with
interstitial.show().catch(...): not loaded, already showing, and platform declines reject the
returned promise, while a destroyed ad, or invalid showOptions on a loaded ad, throw
synchronously (a programmer error to fix at the call site).
Both examples pass the shared RequestOptions supported by the GAM request:
customTargetingsends key/value pairs that Ad Manager can use in line-item targeting. Each value is a string, a number, or an array of strings and numbers; numbers are converted to strings before the request reaches the native SDK. Non-finite numbers (NaN,Infinity) are rejected.categoryExclusionstakes an array of Ad Manager ad exclusion labels; line items and creatives with any of those labels are not served for that request. An empty array sends no exclusions, and non-string members are rejected.publisherProvidedIdandpublisherProvidedSignalsare available for publishers whose Ad Manager setup uses those features.networkExtrassends adapter-specific values; it is not a replacement for GAM custom targeting.
Define the matching keys, values, exclusion labels, and line-item rules in Ad Manager. The client API supplies request signals; it does not create or select line items by ID. See Google's Ad Manager targeting guide for the upstream concepts.
For paid-event payloads and load-time auction metadata, see Revenue telemetry and auction diagnostics.