Retrieve information about the ad response

For debugging and logging purposes, successfully loaded ads provides a ResponseInfo object. This object contains information about the ad it loaded, in addition to information about the mediation waterfall used to load the ad.

For cases where an ad loads successfully, the ad object has a GetResponseInfo() method. For example, InterstitialAd.GetResponseInfo() gets the response info for a loaded interstitial ad.

For cases where ads fail to load and only an error is available, the response info is available through AdFailedToLoadEventArgs.LoadAdError.GetResponseInfo().

InterstitialAd ad;

private void RequestInterstitial()
{
    ad = new InterstitialAd("AD_UNIT_ID");
    this.interstitial.OnAdLoaded += OnAdLoaded;
    this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
    AdRequest request = new AdRequest.Builder().Build();
    this.interstitial.LoadAd(request);
}

private void OnAdLoaded(object sender, EventArgs args)
{
    ResponseInfo info = ad.GetResponseInfo();
}

private void OnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
    ResponseInfo info = args.LoadAdError.GetResponseInfo();
}

Response info

Here is a sample output returned by ResponseInfo.ToString() showing the debugging data returned for a loaded ad:

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

Methods on the ResponseInfo object include:

Method Description
GetAdapterResponses Returns the list of AdapterResponseInfo containing metadata for each adapter included in the ad response. Can be used to debug the waterfall mediation and bidding execution. The order of the list matches the order of the mediation waterfall for this ad request.

See Adapter Response Info for more information.

GetLoadedAdapterResponseInfo Returns the AdapterResponseInfo corresponding to the adapter that loaded the ad.
GetMediationAdapterClassName Returns the mediation adapter class name of the ad network that loaded the ad.
GetResponseId The response identifier is a unique identifier for the ad response. This identifier can be used to identify and block the ad in the Ads Review Center (ARC).
GetResponseExtras Returns extra information about the ad response. Extras can return the following keys:
  • mediation_group_name: Name of the mediation group
  • mediation_ab_test_name: Name of the mediation A/B test, if applicable
  • mediation_ab_test_variant: Variant used in the mediation A/B test, if applicable

Here is a sample reading values from a loaded ResponseInfo:

private void OnAdLoaded(object sender, EventArgs args)
{
  ResponseInfo info = ad.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"];
}

Adapter response info

AdapterResponseInfo contains metadata for each adapter included in the ad response, which can be used to debug the waterfall mediation and bidding execution. The order of the list matches the order of the mediation waterfall for the ad request.

Here is a sample output returned by 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

For each ad network, AdapterResponseInfo provides the following methods:

Method Description
AdError Gets the error associated with the request to the network. Returns null if the network successfully loaded an ad or if the network was not attempted.
AdSourceId Gets the ad source ID associated with this adapter response. For campaigns, 6060308706800320801 is returned for a mediated ads campaign goal type, and 7068401028668408324 is returned for impression and click goal types. See Ad sources for the list of possible ad source IDs when an ad network serves the ad.
AdSourceInstanceId Gets the ad source instance ID associated with this adapter response.
AdSourceInstanceName Gets the ad source instance name associated with this adapter response.
AdSourceName Gets the ad source representing the specific ad network that serves the impression. For campaigns, Mediated House Ads is returned for a mediated ads campaign goal type, and Reservation Campaign is returned for impression and click goal types. See Ad sources for the list of possible ad source names when an ad network serves the ad.
AdapterClassName Gets a class name that identifies the ad network.
AdUnitMapping Gets the network configuration set from the Admob UI.
LatencyMillis Gets the amount of time the ad network spent loading an ad. Returns 0 if the network was not attempted.

Here is a sample reading values from a loaded AdapterResponseInfo:

private void OnAdLoaded(object sender, EventArgs args)
{
  ResponseInfo responseInfo = ad.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;
}