Retrieve 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() .

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

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

Response Info

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

  { 
  
 "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" 
  
 } 
 } 
 

Methods on the ResponseInfo object include the following:

Method
Description
getAdSourceResponses
Returns the list of AdSourceResponseInfo containing metadata for each ad source 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 Ad source response info for more information.

getLoadedAdSourceResponse
Returns the AdSourceResponseInfo corresponding to the ad source that loaded the ad.
getAdapterClassName
Returns the mediation adapter class name of the ad source 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 Ad Review Center (ARC) .
getResponseExtras
Returns extra information about the ad response. Extras may return the following keys:
  • mediation_group_name : The name of the mediation group
  • mediation_ab_test_name : The name of the mediation A/B test , if applicable
  • mediation_ab_test_variant : The variant used in the mediation A/B test, if applicable

Kotlin

  override 
  
 fun 
  
 onAdLoaded 
 ( 
 interstitialAd 
 : 
  
 InterstitialAd 
 ) 
  
 { 
  
 val 
  
 responseInfo 
  
 = 
  
 interstitialAd 
 . 
 responseInfo 
  
 val 
  
 responseId 
  
 = 
  
 responseInfo 
 . 
 responseId 
  
 val 
  
 adapterClassName 
  
 = 
  
 responseInfo 
 . 
 adapterClassName 
  
 val 
  
 adSourceResponses 
  
 = 
  
 responseInfo 
 . 
 adSourceResponses 
  
 val 
  
 loadedAdSourceResponse 
  
 = 
  
 responseInfo 
 . 
 loadedAdSourceResponse 
  
 val 
  
 extras 
  
 = 
  
 responseInfo 
 . 
 responseExtras 
  
 val 
  
 mediationGroupName 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_group_name" 
 ) 
  
 val 
  
 mediationABTestName 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_ab_test_name" 
 ) 
  
 val 
  
 mediationABTestVariant 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_ab_test_variant" 
 ) 
 } 
 

Java

  @Override 
 public 
  
 void 
  
 onAdLoaded 
 ( 
 @NonNull 
  
 InterstitialAd 
  
 interstitialAd 
 ) 
  
 { 
  
 MyActivity 
 . 
 this 
 . 
 interstitialAd 
  
 = 
  
 interstitialAd 
 ; 
  
 ResponseInfo 
  
 responseInfo 
  
 = 
  
 interstitialAd 
 . 
 getResponseInfo 
 (); 
  
 String 
  
 responseId 
  
 = 
  
 responseInfo 
 . 
 getResponseId 
 (); 
  
 String 
  
 adapterClassName 
  
 = 
  
 responseInfo 
 . 
 getAdapterClassName 
 (); 
  
 List<AdSourceResponseInfo> 
  
 adSourceResponses 
  
 = 
  
 responseInfo 
 . 
 getAdSourceResponses 
 (); 
  
 AdSourceResponseInfo 
  
 loadedAdSourceResponse 
  
 = 
  
 responseInfo 
 . 
 getLoadedAdSourceResponse 
 (); 
  
 Bundle 
  
 extras 
  
 = 
  
 responseInfo 
 . 
 getResponseExtras 
 (); 
  
 String 
  
 mediationGroupName 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_group_name" 
 ); 
  
 String 
  
 mediationABTestName 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_ab_test_name" 
 ); 
  
 String 
  
 mediationABTestVariant 
  
 = 
  
 extras 
 . 
 getString 
 ( 
 "mediation_ab_test_variant" 
 ); 
 } 
 

Ad source response info

AdSourceResponseInfo contains response information for an individual ad source in an ad response.

The following sample AdSourceResponseInfo output shows the metadata for a loaded ad:

  { 
  
 "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" 
 } 
 

For each ad source, AdSourceResponseInfo provides the following methods:

Method Description
getAdError Gets the error associated with the request to the ad source. Returns null if the ad source successfully loaded an ad or if the ad source was not attempted.
getId Gets the ad source ID associated with this ad source 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 source serves the ad.
getInstanceId Gets the ad source instance ID associated with this adapter response.
getInstanceName Gets the ad source instance name associated with this adapter response.
getName Gets the ad source name associated with this adapter response. 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 source serves the ad.
getAdapterClassName Gets the class name of the ad source adapter that loaded the ad.
getCredentials Gets the ad source adapter credentials specified in the AdMob UI.
getLatencyMillis Gets the amount of time the ad source adapter spent loading an ad. Returns 0 if the ad source was not attempted.

Kotlin

  override 
  
 fun 
  
 onAdLoaded 
 ( 
 interstitialAd 
 : 
  
 InterstitialAds 
 ) 
  
 { 
  
 val 
  
 loadedAdSourceResponseInfo 
  
 = 
  
 interstitialAd 
 . 
 responseInfo 
 . 
 loadedAdSourceResponse 
  
 val 
  
 adError 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 adError 
  
 val 
  
 adSourceId 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 id 
  
 val 
  
 adSourceInstanceId 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 instanceId 
  
 val 
  
 adSourceInstanceName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 instanceName 
  
 val 
  
 adSourceName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 name 
  
 val 
  
 adapterClassName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 adapterClassName 
  
 val 
  
 credentials 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 credentials 
  
 val 
  
 latencyMillis 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 latencyMillis 
 } 
 

Java

  @Override 
 public 
  
 void 
  
 onAdLoaded 
 ( 
 @NonNull 
  
 InterstitialAd 
  
 interstitialAd 
 ) 
  
 { 
  
 AdSourceResponseInfo 
  
 loadedAdSourceResponseInfo 
  
 = 
  
 interstitialAd 
 . 
 getResponseInfo 
 (). 
 getLoadedAdSourceResponse 
 (); 
  
 AdError 
  
 adError 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getAdError 
 (); 
  
 String 
  
 adSourceId 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getId 
 (); 
  
 String 
  
 adSourceInstanceId 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getInstanceId 
 (); 
  
 String 
  
 adSourceInstanceName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getInstanceName 
 (); 
  
 String 
  
 adSourceName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getName 
 (); 
  
 String 
  
 adapterClassName 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getAdapterClassName 
 (); 
  
 Bundle 
  
 credentials 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getCredentials 
 (); 
  
 long 
  
 latencyMillis 
  
 = 
  
 loadedAdSourceResponseInfo 
 . 
 getLatencyMillis 
 (); 
 } 
 
Design a Mobile Site
View Site in Mobile | Classic
Share by: