Segment ad data with placements

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 GMA Next-Gen SDK and viewing an ad performance report.

Prerequisites

Before you continue, do the following:

  • Complete Set up GMA Next-Gen SDK.
  • Have GMA Next-Gen SDK version 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 GMA Next-Gen 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:

Kotlin

private fun loadInterstitial() {
  val adRequest = AdRequest.Builder("AD_UNIT_ID").setPlacementId(PLACEMENT_ID).build()
  InterstitialAd.load(
    adRequest,
    object : AdLoadCallback<InterstitialAd> {
      override fun onAdLoaded(ad: InterstitialAd) {
        Log.d(TAG, "Placement ID: " + ad.placementId)
      }
    },
  )
}

Java

private void loadInterstitial() {
  AdRequest adRequest = new AdRequest.Builder("AD_UNIT_ID").setPlacementId(PLACEMENT_ID).build();
  InterstitialAd.load(
      adRequest,
      new AdLoadCallback<>() {
        @Override
        public void onAdLoaded(InterstitialAd ad) {
          Log.d(TAG, "Placement ID: " + ad.getPlacementId());
        }
      });
}

Replace the following values:

  • AD_UNIT_ID with your ad unit ID.
  • PLACEMENT_ID 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:

Kotlin

private fun showBannerView(ad: BannerAd, parentView: ViewGroup, activity: Activity) {
  ad.placementId = PLACEMENT_ID
  parentView.addView(ad.getView(activity))
}

Java

private void showBannerView(BannerAd ad, ViewGroup parentView, Activity activity) {
  ad.setPlacementId(PLACEMENT_ID);
  parentView.addView(ad.getView(activity));
}

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:

Kotlin

private fun showAd(activity: Activity, ad: InterstitialAd) {
  ad.placementId = PLACEMENT_ID
  ad.show(activity)
}

Java

private void showAd(Activity activity, InterstitialAd ad) {
  ad.setPlacementId(PLACEMENT_ID);
  ad.show(activity);
}

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:

Kotlin

private fun showNativeAd(nativeAdView: NativeAdView, nativeAd: NativeAd, mediaView: MediaView) {
  nativeAd.placementId = PLACEMENT_ID
  nativeAdView.registerNativeAd(nativeAd, mediaView)
}

Java

private void showNativeAd(NativeAdView nativeAdView, NativeAd nativeAd, MediaView mediaView) {
  nativeAd.setPlacementId(PLACEMENT_ID);
  nativeAdView.registerNativeAd(nativeAd, mediaView);
}

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.