This guide explains how to integrate custom native ad formats with open measurement.
Prerequisites
Before you continue, do the following:
- Read Open Measurement with the Mobile Ads SDK.
- Integrate custom native ad formats.
- Configure a viewability provider and assign it to your line item.
- Enter your partner name when creating a custom format in the Ad Manager UI.
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.
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 custom native ad:
Java
Kotlin
Replace AD_UNIT_ID and CUSTOM_TEMPLATE_ID with your ad unit ID and custom template ID.
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: