Display-type custom native ad formats and Open Measurement

  • This guide details how to integrate custom native ad formats with Open Measurement.

  • Integration requires reading documentation, integrating custom native ad formats, configuring a viewability provider, and entering your partner name.

  • For custom native ads without video, you need to call the Open Measurement APIs yourself.

  • If you have a video asset in your custom native ad, the Mobile Ads SDK handles viewability tracking.

  • To enable Open Measurement on a custom native ad, register your view with DisplayOpenMeasurement and call the start() method.

  • You must certify with the IAB Tech Lab as a Measurement Provider for your display-type native custom ad measurement results to be certified.

This guide explains how to integrate custom native ad formats with open measurement.

Prerequisites

Before you continue, do the following:

Integration

If you plan to use open measurement with custom native ad formats that don't contain a video asset, you'll be responsible for calling the Open Measurement APIs yourself.

If you're using custom native ad formats with a video asset, you don't need to follow this guide; the Mobile Ads SDK tracks viewability of the video asset on your behalf.

Register your view and begin measuring

To enable open measurement on a custom native ad, display the ad first, and then register your custom ad view with the DisplayOpenMeasurement object associated with the custom native ad. The DisplayOpenMeasurement object provides the setView() method to register your container view with open measurement.

You also need to explicitly tell the SDK to begin measuring your ad. To do this call the start() method on the DisplayOpenMeasurement object of your custom native ad. The start() method must be called from the main thread, and subsequent calls have no effect.

Here's what it looks like:

Kotlin

@MainThread
private fun displayCustomNativeAd(
  customNativeAd: CustomNativeAd,
  nativeAdViewContainer: FrameLayout,
) {
  // TODO: Render the custom native ad inside the nativeAdViewContainer.

  // ...

  // Start measuring the ad view.
  val displayOpenMeasurement = customNativeAd.getDisplayOpenMeasurement()
  if (displayOpenMeasurement != null) {
    displayOpenMeasurement.setView(nativeAdViewContainer)
    displayOpenMeasurement.start()
  }
}

Java

@MainThread
private void displayCustomNativeAd(
    CustomNativeAd customNativeAd, FrameLayout nativeAdViewContainer) {
  // TODO: Render the custom native ad inside the nativeAdViewContainer.

  // ...

  // Start measuring the ad view.
  DisplayOpenMeasurement displayOpenMeasurement = customNativeAd.getDisplayOpenMeasurement();
  if (displayOpenMeasurement != null) {
    displayOpenMeasurement.setView(nativeAdViewContainer);
    displayOpenMeasurement.start();
  }
}

Note that you should display your ad before registering your view. Displaying your ad is covered in Custom Native Ad Formats.

The nativeAdViewContainer layout is the ad container for the custom native ad and must contain all assets within the bounding box of the view.

Certify with IAB

Once you release your app, you will begin receiving measurement data; however, your data won't be certified until you complete the IAB certification process.