広告レスポンスに関する情報を取得する

広告が正常に読み込まれた場合は、デバッグとロギングを行うため ResponseInfo オブジェクトが提供されます。このオブジェクトには、広告の読み込みに使用されたメディエーション ウォーターフォールに関する情報に加え、読み込まれた広告に関する情報が含まれます。

広告が正常に読み込まれる場合、広告オブジェクトは GetResponseInfo() メソッドを持ちます。たとえば、interstitialAd.GetResponseInfo() は読み込まれたインタースティシャル広告のレスポンス情報を取得します。

広告の読み込みに失敗し、エラーしかない場合は、LoadAdError.GetResponseInfo() からレスポンス情報を確認できます。

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        ResponseInfo errorInfo = error.GetResponseInfo();
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo loadInfo = insterstitialAd.GetResponseInfo();
  });
}

回答情報

次の出力例は ResponseInfo.ToString() から返されるもので、読み込まれた広告に対して返されるデバッグデータを示しています。

Android

{
  "Response ID": "COOllLGxlPoCFdAx4Aod-Q4A0g",
  "Mediation Adapter Class Name": "com.google.ads.mediation.admob.AdMobAdapter",
  "Adapter Responses": [
    {
      "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
      "Latency": 328,
      "Ad Source Name": "Reservation campaign",
      "Ad Source ID": "7068401028668408324",
      "Ad Source Instance Name": "[DO NOT EDIT] Publisher Test Interstitial",
      "Ad Source Instance ID": "4665218928925097",
      "Credentials": {},
      "Ad Error": "null"
    }
  ],
  "Loaded Adapter Response": {
    "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
    "Latency": 328,
    "Ad Source Name": "Reservation campaign",
    "Ad Source ID": "7068401028668408324",
    "Ad Source Instance Name": "[DO NOT EDIT] Publisher Test Interstitial",
    "Ad Source Instance ID": "4665218928925097",
    "Credentials": {},
    "Ad Error": "null"
  },
  "Response Extras": {
    "mediation_group_name": "Campaign"
  }
}

iOS

 ** Response Info **
    Response ID: CIzs0ZO5kPoCFRqWAAAdJMINpQ
    Network: GADMAdapterGoogleAdMobAds

  ** Loaded Adapter Response **
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name: Reservation campaign
    Ad Source ID: 7068401028668408324
    Ad Source Instance Name: [DO NOT EDIT] Publisher Test Interstitial
    Ad Source Instance ID: [DO NOT EDIT] Publisher Test Interstitial
    AdUnitMapping:
    {
    }
    Error: (null)
    Latency: 0.391

  ** Extras Dictionary **
    {
        "mediation_group_name" = Campaign;
    }

  ** Mediation line items **
    Entry (1)
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name: Reservation campaign
    Ad Source ID:7068401028668408324
    Ad Source Instance Name: [DO NOT EDIT] Publisher Test Interstitial
    Ad Source Instance ID: [DO NOT EDIT] Publisher Test Interstitial
    AdUnitMapping:
    {
    }
    Error: (null)
    Latency: 0.391

ResponseInfo オブジェクトのメソッドには次のものがあります。

メソッド 説明
GetAdapterResponses 広告レスポンスに含まれる各アダプタのメタデータを含む AdapterResponseInfo のリストを返します。ウォーターフォール メディエーションと入札の実行のデバッグに使用できます。リストの順序は、この広告リクエストのメディエーション ウォーターフォールの順序と同じです。

詳しくは、アダプタ レスポンス情報をご覧ください。

GetLoadedAdapterResponseInfo 広告を読み込んだアダプタに対応する AdapterResponseInfo を返します。
GetMediationAdapterClassName 広告を読み込んだ広告ネットワークのメディエーション アダプタのクラス名を返します。
GetResponseId レスポンス ID は、広告レスポンスの一意の識別子です。この識別子は、広告レビュー センター(ARC)で広告を識別してブロックするために使用されます。
GetResponseExtras 広告レスポンスに関する追加情報を返します。エクストラは次のキーを返すことができます。
  • mediation_group_name: メディエーション グループの名前
  • mediation_ab_test_name: メディエーション A/B テストの名前(該当する場合)
  • mediation_ab_test_variant: メディエーションの A/B テストで使用されるパターン(該当する場合)

読み込まれた ResponseInfo から値を読み取る例を次に示します。

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo responseInfo = insterstitialAd.GetResponseInfo();
    string responseId = responseInfo.GetResponseId();
    string mediationAdapterClassName = responseInfo.GetMediationAdapterClassName();
    List<AdapterResponseInfo> adapterResponses = responseInfo.GetAdapterResponses();
    AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.GetLoadedAdapterResponseInfo();
    Dictionary<string, string> extras = responseInfo.GetResponseExtras();
    string mediationGroupName = extras["mediation_group_name"];
    string mediationABTestName = extras["mediation_ab_test_name"];
    string mediationABTestVariant = extras["mediation_ab_test_variant"]; 
  });
}

アダプター レスポンス情報

AdapterResponseInfo には広告レスポンスに含まれる各アダプタのメタデータが含まれ、ウォーターフォール メディエーションと入札の実行をデバッグするために使用できます。リストの順序は、広告リクエストのメディエーション ウォーターフォールの順序と同じです。

AdapterResponseInfo から返される出力例を次に示します。

Android

{
  "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
  "Latency": 328,
  "Ad Source Name": "Reservation campaign",
  "Ad Source ID": "7068401028668408324",
  "Ad Source Instance Name": "[DO NOT EDIT] Publisher Test Interstitial",
  "Ad Source Instance ID": "4665218928925097",
  "Credentials": {},
  "Ad Error": "null"
}

iOS

  Network: GADMAdapterGoogleAdMobAds
  Ad Source Name: Reservation campaign
  Ad Source ID: 7068401028668408324
  Ad Source Instance Name: [DO NOT EDIT] Publisher Test Interstitial
  Ad Source Instance ID: [DO NOT EDIT] Publisher Test Interstitial
  AdUnitMapping:
  {
  }
  Error: (null)
  Latency: 0.391

AdapterResponseInfo は、広告ネットワークごとに次のメソッドを提供します。

メソッド 説明
AdError ネットワークへのリクエストに関連するエラーを取得します。ネットワークが広告を正常に読み込んだか、実行を試行しなかった場合は、null が返されます。
AdSourceId このアダプタ レスポンスに関連付けられている広告ソース ID を取得します。キャンペーンでは、メディエーションされる広告のキャンペーン目標タイプに対して 6060308706800320801 が返され、インプレッションおよびクリックの目標タイプに対して 7068401028668408324 が返されます。広告ネットワークから広告が配信される際に使用可能な広告ソース ID のリストについては、広告のソースをご覧ください。
AdSourceInstanceId このアダプタ レスポンスに関連付けられている広告ソースのインスタンス ID を取得します。
AdSourceInstanceName このアダプタ レスポンスに関連付けられている広告ソースのインスタンス名を取得します。
AdSourceName 広告を配信する特定の広告ネットワークを表す広告ソースを取得します。キャンペーンでは、メディエーションされる広告のキャンペーン目標タイプに対して Mediated House Ads が返され、インプレッションおよびクリックの目標タイプに対して Reservation Campaign が返されます。広告ネットワークから広告が配信される際に返される広告ソースの名前の一覧については、広告のソースをご覧ください。
AdapterClassName 広告ネットワークを識別するクラス名を取得します。
AdUnitMapping AdMob 管理画面からネットワーク構成セットを取得します。
LatencyMillis 広告ネットワークが広告の読み込みに費やした時間を取得します。ネットワークが試行されていない場合は 0 を返します。

読み込まれた AdapterResponseInfo から値を読み取る例を次に示します。

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo responseInfo = insterstitialAd.GetResponseInfo();
    AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.getLoadedAdapterResponseInfo();
    AdError adError = loadedAdapterResponseInfo.AdError;
    string adSourceId = loadedAdapterResponseInfo.AdSourceId;
    string adSourceInstanceId = loadedAdapterResponseInfo.AdSourceInstanceId;
    string adSourceInstanceName = loadedAdapterResponseInfo.AdSourceInstanceName;
    string adSourceName = loadedAdapterResponseInfo.AdSourceName;
    string adapterClassName = loadedAdapterResponseInfo.AdapterClassName;
    Dictionary<string, string> credentials = loadedAdapterResponseInfo.AdUnitMapping;
    long latencyMillis = loadedAdapterResponseInfo.LatencyMillis;
  });
}