Google Ad Manager

Use Google Ad Manager (GAM) components and options, including GAM banners and interstitials.

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.

GAM banner

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:

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

GAM interstitial

useGAMInterstitialAd owns one Ad Manager interstitial with the same status lifecycle as the other options-form hooks, and adds GAM app events through onAppEvent.

tsx
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()} />
  );
}
  • onAppEvent receives { 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, so onPress={() => 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's ERROR event surfaces as status: 'error' with error set.
  • The hook does not preload the next ad after closed; call load() 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).

Target line items

Both examples pass the shared RequestOptions supported by the GAM request:

  • customTargeting sends 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.
  • categoryExclusions takes 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.
  • publisherProvidedId and publisherProvidedSignals are available for publishers whose Ad Manager setup uses those features.
  • networkExtras sends 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.