ディスプレイ タイプのカスタム ネイティブ広告フォーマットと Open Measurement

このガイドでは、カスタム ネイティブ広告フォーマットをオープン測定と統合する方法について説明します。

前提条件

続行する前に、次のことを行います。

統合

動画アセットを含まないカスタム ネイティブ広告フォーマットで Open Measurement を使用する場合は、Open Measurement API を自分で呼び出す必要があります。

動画アセットを含むカスタム ネイティブ広告フォーマットを使用している場合は、このガイドに沿って作業する必要はありません。Mobile Ads SDK が動画アセットの視認性をトラッキングします。

ビューを登録して測定を開始する

カスタム ネイティブ広告で Open Measurement を有効にするには、まず広告を表示してから、カスタム ネイティブ広告に関連付けられた DisplayOpenMeasurement オブジェクトを使用してカスタム広告ビューを登録します。DisplayOpenMeasurement オブジェクトは、コンテナビューをオープン測定に登録するための setView() メソッドを提供します。

また、広告の測定を開始するよう SDK に明示的に指示する必要があります。これを行うには、カスタム ネイティブ広告の DisplayOpenMeasurement オブジェクトで start() メソッドを呼び出します。start() メソッドはメインスレッドから呼び出す必要があります。以降の呼び出しは無効です。

画面のサンプルを次に示します。

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();
  }
}

ビューを登録する前に広告を表示する必要があります。広告の表示については、カスタム ネイティブ広告フォーマットをご覧ください。

nativeAdViewContainer レイアウトはカスタム ネイティブ広告の広告コンテナであり、ビューのバウンディング ボックス内のすべてのアセットを含んでいる必要があります。

IAB で認定を受ける

アプリをリリースすると、測定データの受信が開始されますが、IAB 認定プロセスを完了するまで、データは認定されません。