Segment ad data with placements

  • The ad placements feature is used to segment ad performance reporting data without needing additional ad units.

  • To use the placements feature, you need access to the placement ID feature and a created placement ID for your app.

  • You can set a placement ID in the Google Mobile Ads SDK either when loading the ad or before showing the ad.

  • The Google Mobile Ads SDK uses the latest set placement ID when it records an ad impression.

  • After setting the placement ID, you can view a report of the placement ID dimension in the AdMob UI under the Reports section.

To segment your ad performance reporting data, use the ad placements feature. Placements let you segment impression data in a report without needing additional ad units. To use the placements feature, you need a placement ID. For details on placements, see About placements.

This guide covers setting a placement ID in Google Mobile Ads SDK and viewing an ad performance report.

Prerequisites

Before you continue, do the following:

  • Complete Set up Google Mobile Ads SDK.
  • Have Google Mobile Ads SDK version 12.9.0 or higher.
  • Get access to the placement ID feature. To request access, contact your account manager.
  • Create a placement ID for your app.

Set a placement ID

To segment your ad's performance data, you set a placement ID in one of the following ways:

  • When loading the ad.
  • Before showing the ad.

You can update the placement ID as needed. When Google Mobile Ads SDK records an ad impression, it uses the latest set placement ID.

Set a placement ID at load time

This section covers setting a placement ID at load time. This workflow applies for all ad formats.

The following example sets a placement ID for an interstitial ad at load time:

Swift

private func loadInterstitial() async {
  do {
    let interstitial = try await InterstitialAd.load(
      with: "adUnitID", request: Request())
    interstitial.placementID = adPlacementID
    print("Placement ID set to: \(interstitial.placementID)")
  } catch {
    print("Failed to load interstitial ad with error: \(error.localizedDescription)")
  }
}

Objective-C

- (void)loadInterstitial {
  GADRequest *request = [GADRequest request];
  request.placementID = adPlacementID;
  [GADInterstitialAd loadWithAdUnitID:"adUnitID"
                              request:request
                    completionHandler:^(GADInterstitialAd *ad, NSError *error) {
                      if (!error) {
                        NSLog(@"Placement ID: %lld", ad.placementID);
                        return;
                      }
                    }];
}

Replace the following values:

  • adUnitID with your ad unit ID.
  • adPlacementID with your placement ID.

Set placement ID at show time

This section covers setting a placement ID at show time for all ad formats. Select your preferred ad formats from the following sections:

For banner ads, you set the placement ID before placing the ad view in the view hierarchy. The following example sets a placement ID for a banner ad at show time:

Swift

private func showBanner(_ bannerView: BannerView) {
  bannerView.placementID = adPlacementID
  view.addSubview(bannerView)
}

Objective-C

- (void)showBannerView:(GADBannerView *)bannerView {
  bannerView.placementID = adPlacementID;
  [self.view addSubview:bannerView];
}

Full-screen ads

For full-screen ad formats, you set the placement ID before showing an ad. This workflow applies to the following formats:

The following example sets the placement ID for an interstitial ad at show time:

Swift

private func showInterstitial(_ ad: InterstitialAd) {
  ad.placementID = adPlacementID
  ad.present(from: self)
}

Objective-C

- (void)showAd:(GADInterstitialAd *)ad {
  ad.placementID = adPlacementID;
  [ad presentFromRootViewController:self];
}

Native ads

For native ads, you set the placement ID after you load a native ad and before registering the ad to the ad view.

The following example sets a placement ID for a native ad at show time:

Swift

private func configureView(_ nativeAdView: NativeAdView, withAd nativeAd: NativeAd) {
  nativeAd.placementID = adPlacementID
  nativeAdView.nativeAd = nativeAd
}

Objective-C

- (void)configureView:(GADNativeAdView *)nativeAdView withNativeAd:(GADNativeAd *)nativeAd {
  nativeAd.placementID = adPlacementID;
  nativeAdView.nativeAd = nativeAd;
}

View placements report

After you set the placement ID, you see a report of the placement ID dimension in the AdMob UI. To view the report, follow View your placements.