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

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

前提条件

先に進む前に、次のことを実施してください。

統合

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

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

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

カスタム ネイティブ広告で Open Measurement を有効にするには、まず広告を表示し、次にカスタム ネイティブ広告に関連付けられている DisplayOpenMeasurement オブジェクトにカスタム広告ビューを登録します。DisplayOpenMeasurement オブジェクトには、コンテナビューを Open Measurement に登録するための 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 の認定プロセスを完了するまでデータは認定されません