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
@MainThreadprivatefundisplayCustomNativeAd(customNativeAd:CustomNativeAd,nativeAdViewContainer:FrameLayout,){// TODO: Render the custom native ad inside the nativeAdViewContainer.// ...// Start measuring the ad view.valdisplayOpenMeasurement=customNativeAd.getDisplayOpenMeasurement()if(displayOpenMeasurement!=null){displayOpenMeasurement.setView(nativeAdViewContainer)displayOpenMeasurement.start()}}
Java
@MainThreadprivatevoiddisplayCustomNativeAd(CustomNativeAdcustomNativeAd,FrameLayoutnativeAdViewContainer){// TODO: Render the custom native ad inside the nativeAdViewContainer.// ...// Start measuring the ad view.DisplayOpenMeasurementdisplayOpenMeasurement=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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["This guide explains how to integrate custom native ad formats with open\nmeasurement.\n\nPrerequisites\n\nBefore you continue, do the following:\n\n- Read [Open Measurement with the Mobile Ads\n SDK](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/open-measurement).\n- Integrate [custom native ad\n formats](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/native/custom-formats).\n- [Configure a viewability\n provider](//support.google.com/admanager/answer/9025968#configure-a-viewability-provider) and assign it to your line item.\n- Enter your partner name when [creating a custom\n format](//support.google.com/admanager/answer/7661908) in the Ad Manager UI.\n\nIntegration\n\nIf you plan to use open measurement with custom native ad formats that\ndon't contain a video asset, you'll be responsible for calling the Open\nMeasurement APIs yourself.\n\nIf you're using custom native ad formats with a video asset, you don't need to\nfollow this guide; the Mobile Ads SDK tracks viewability of the video asset on\nyour behalf.\n| **Key Point:** In order for your display-type native custom ad measurement results to be certified by the IAB, you must be certified as a Measurement Provider with the [IAB Tech Lab](//iabtechlab.com/compliance-programs/faq-om-sdk-compliance/).\n\n\u003cbr /\u003e\n\nRegister your view and begin measuring\n\nTo enable open measurement on a custom native ad, display the ad first, and then\nregister your custom ad view with the `DisplayOpenMeasurement` object associated\nwith the custom native ad. The `DisplayOpenMeasurement` object provides the\n`setView()` method to register your container view with open measurement.\n\nYou also need to explicitly tell the SDK to begin measuring your ad. To do this\ncall the `start()` method on the `DisplayOpenMeasurement` object of your\ncustom native ad. The `start()` method must be called from the main\nthread, and subsequent calls have no effect.\n\nHere's what it looks like: \n\nKotlin \n\n @MainThread\n private fun displayCustomNativeAd(\n customNativeAd: CustomNativeAd,\n nativeAdViewContainer: FrameLayout,\n ) {\n // TODO: Render the custom native ad inside the nativeAdViewContainer.\n\n // ...\n\n // Start measuring the ad view.\n val displayOpenMeasurement = customNativeAd.getDisplayOpenMeasurement()\n if (displayOpenMeasurement != null) {\n displayOpenMeasurement.setView(nativeAdViewContainer)\n displayOpenMeasurement.start()\n }\n }\n\nJava \n\n @MainThread\n private void displayCustomNativeAd(\n CustomNativeAd customNativeAd, FrameLayout nativeAdViewContainer) {\n // TODO: Render the custom native ad inside the nativeAdViewContainer.\n\n // ...\n\n // Start measuring the ad view.\n DisplayOpenMeasurement displayOpenMeasurement = customNativeAd.getDisplayOpenMeasurement();\n if (displayOpenMeasurement != null) {\n displayOpenMeasurement.setView(nativeAdViewContainer);\n displayOpenMeasurement.start();\n }\n }\n\nNote that you should display your ad before registering your view. Displaying\nyour ad is covered in [Custom Native Ad\nFormats](/ad-manager/mobile-ads-sdk/android/early-access/nextgen/native/custom-formats#display_custom_native_ad_formats).\n\nThe `nativeAdViewContainer`\nlayout is the ad container for the custom native ad and must contain all\nassets within the bounding box of the view.\n| **Important:** Make sure you call `destroy()` on the custom native ad when you're done with the ad, for example, after dereferencing the object or destroying the activity. This makes sure that the IAB `sessionFinish` event is fired.\n\nCertify with IAB\n\nOnce you release your app, you will begin receiving measurement data; however,\nyour data won't be certified until you complete the\n[IAB certification process](//iabtechlab.com/compliance-programs/faq-om-sdk-compliance/)."]]