Retrieving Information about the Ad Response

For debugging and logging purposes, successfully loaded ads provide 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 LoadAdError.getResponseInfo().

Java

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  ResponseInfo responseInfo = interstitialAd.getResponseInfo();
  Log.d(TAG, responseInfo.toString());
}

@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
  ResponseInfo responseInfo = loadAdError.getResponseInfo();
  Log.d(TAG, responseInfo.toString());
}

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAd)) {
  val responseInfo = interstitialAd.responseInfo
  Log.d(TAG, responseInfo.toString())
}

override fun onAdFailedToLoad(adError: LoadAdError) {
  val responseInfo = adError.responseInfo
  Log.d(TAG, responseInfo.toString())
}

Response Info

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

{
  "Response ID": "NI3BZZDbGdyQtOUP4o21gAM",
  "Mediation Adapter Class Name": "com.google.ads.mediation.admob.AdMobAdapter",
  "Adapter Responses": [
    {
      "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
      "Latency": 3585,
      "Ad Source Name": "AdMob Network",
      "Ad Source ID": "",
      "Ad Source Instance Name": "AdMob (default)",
      "Ad Source Instance ID": "",
      "Credentials": {
        "pubid": "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=8e&caqid=NI3BZfDhGICQtOUP7ayS4Aw"
      },
      "Ad Error": "null"
    }
  ],
  "Loaded Adapter Response": {
    "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
    "Latency": 3585,
    "Ad Source Name": "AdMob Network",
    "Ad Source ID": "",
    "Ad Source Instance Name": "AdMob (default)",
    "Ad Source Instance ID": "",
    "Credentials": {
      "pubid": "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=8e&caqid=NI3BZfDhGICQtOUP7ayS4Aw"
    },
    "Ad Error": "null"
  },
  "Response Extras": {}
}

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.

Java

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  MyActivity.this.interstitialAd = interstitialAd;

  ResponseInfo responseInfo = interstitialAd.getResponseInfo();
  String responseId = responseInfo.getResponseId();
  String mediationAdapterClassName = responseInfo.getMediationAdapterClassName();
  List&ltAdapterResponseInfo> adapterResponses = responseInfo.getAdapterResponses();
  AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.getLoadedAdapterResponseInfo();
}

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAd)) {
  val responseInfo = interstitialAd.responseInfo

  val responseId = responseInfo.responseId
  val mediationAdapterClassName = responseInfo.mediationAdapterClassName
  val adapterResponses = responseInfo.adapterResponses
  val loadedAdapterResponseInfo = responseInfo.loadedAdapterResponseInfo
}

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 sample AdapterResponseInfo output:

{
  "Adapter": "com.google.ads.mediation.admob.AdMobAdapter",
  "Latency": 3585,
  "Ad Source Name": "AdMob Network",
  "Ad Source ID": "",
  "Ad Source Instance Name": "AdMob (default)",
  "Ad Source Instance ID": "",
  "Credentials": {
    "pubid": "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=8e&caqid=NI3BZfDhGICQtOUP7ayS4Aw"
  },
  "Ad Error": "null"
}

For each ad network, AdapterResponseInfo provides the following methods:

Method Description
getAdError 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.
getAdSourceId Gets the ad source ID associated with this adapter response.
getAdSourceInstanceId Gets the ad source instance ID associated with this adapter response. Returns an empty string if not filled by a yield group.
getAdSourceInstanceName Gets the ad source instance name associated with this adapter response.
getAdSourceName Gets the ad source representing the specific ad network that serves the impression.
getAdapterClassName Gets the class name of the adapter that loaded the ad.
getCredentials Gets the network configuration set from the Ad Manager UI.
getLatencyMillis Gets the amount of time the ad network spent loading an ad. Returns 0 if the network was not attempted.

Java

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  AdapterResponseInfo loadedAdapterResponseInfo =
      interstitialAd.getResponseInfo().getLoadedAdapterResponseInfo();

  AdError adError = loadedAdapterResponseInfo.getAdError();
  String adSourceId = loadedAdapterResponseInfo.getAdSourceId();
  String adSourceInstanceId = loadedAdapterResponseInfo.getAdSourceInstanceId();
  String adSourceInstanceName = loadedAdapterResponseInfo.getAdSourceInstanceName();
  String adSourceName = loadedAdapterResponseInfo.getAdSourceName();
  String adapterClassName = loadedAdapterResponseInfo.getAdapterClassName();
  Bundle credentials = loadedAdapterResponseInfo.getCredentials();
  long latencyMillis = loadedAdapterResponseInfo.getLatencyMillis();
}

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAds) {
  val loadedAdapterResponseInfo = interstitialAd.responseInfo.loadedAdapterResponse

  val adError = loadedAdapterResponseInfo.adError
  val adSourceId = loadedAdapterResponseInfo.adSourceId
  val adSourceInstanceId = loadedAdapterResponseInfo.adSourceInstanceId
  val adSourceInstanceName = loadedAdapterResponseInfo.adSourceInstanceName
  val adSourceName = loadedAdapterResponseInfo.adSourceName
  val adapterClassName = loadedAdapterResponseInfo.adapterClassName
  val credentials = loadedAdapterResponseInfo.credentials
  val latencyMillis = loadedAdapterResponseInfo.latencyMillis
}