Display-type Custom Native Ad Formats and Open Measurement

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



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. Open measurement for display-type custom native ad formats is only supported by the Mobile Ads SDK version 18.1.1 and later.

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.

Load an ad

Loading an ad is the same whether you're using open measurement or not. Here is a method that demonstrates how to request a NativeCustomFormatAd:

public void loadAd() {
   AdLoader adLoader = new AdLoader.Builder(context, "YOUR-AD-UNIT-ID")
      new NativeCustomFormatAd.OnCustomFormatAdLoadedListener() {
          public void onCustomFormatAdLoaded(NativeCustomFormatAd ad) {
              // Register your view and begin open measurement.
              // We will define this method below.
      new NativeCustomFormatAd.OnCustomClickListener() {
          public void onCustomClick(NativeCustomFormatAd ad, String s) {
              // Handle the click action
    .withAdListener( ... )
    .withNativeAdOptions( ... )

Register your view and begin measuring

To enable open measurement on a NativeCustomFormatAd, register your custom ad view with the DisplayOpenMeasurement object associated with the NativeCustomFormatAd. 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 NativeCustomFormatAd. The start() method must be called from the main thread, and subsequent calls have no effect.

Here's what it looks like:

public void  registerOpenMeasurementAndShowAd(NativeCustomFormatAd ad) {

// Show ad
// Begin Open Measurement
// The FrameLayout that will contain your native custom ad
FrameLayout customTemplateAdFrame = (FrameLayout) findViewById(R.id.custom_ad_frame);


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

The customTemplateAdFrame layout is the ad container for the NativeCustomFormatAd 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.