Retrieve information about the ad response

Select platform: Android iOS Unity Flutter

For debugging and logging purposes, successfully loaded ads provide a GADResponseInfo 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 GADResponseInfo property. For example, GADInterstitialAd.responseInfo gets the response info for a loaded interstitial ad.

For cases where ads fail to load and only an error is available, the GADResponseInfo is available using the key GADErrorUserInfoKeyResponseInfo on the error's userInfo dictionary.

Swift

 fileprivate 
  
 func 
  
 loadInterstitial 
 () 
  
 { 
  
 InterstitialAd 
 . 
 load 
 ( 
  
 with 
 : 
  
 " ca-app-pub-3940256099942544/4411468910 
" 
 , 
  
 request 
 : 
  
 request 
  
 ) 
  
 { 
  
 ( 
 ad 
 , 
  
 error 
 ) 
  
 in 
  
 if 
  
 let 
  
 error 
  
 = 
  
 error 
  
 { 
  
 let 
  
 responseInfo 
  
 = 
  
 ( 
 error 
  
 as 
  
 NSError 
 ). 
 userInfo 
 [ 
 GADErrorUserInfoKeyResponseInfo 
 ] 
  
 as 
 ? 
  
 ResponseInfo 
  
 print 
 ( 
 " 
 \( 
 String 
 ( 
 describing 
 : 
  
 responseInfo 
 )) 
 " 
 ) 
  
 return 
  
 } 
  
 let 
  
 responseInfo 
  
 = 
  
 ad 
 ?. 
 responseInfo 
  
 print 
 ( 
 " 
 \( 
 String 
 ( 
 describing 
 : 
  
 responseInfo 
 )) 
 " 
 ) 
  
 } 
 } 

Objective-C

 - 
 ( 
 void 
 ) 
 loadInterstitial 
  
 { 
  
 [ 
 GADInterstitialAd 
  
 loadWithAdUnitID 
 : 
 @" ca-app-pub-3940256099942544/4411468910 
" 
  
 request 
 : 
 request 
  
 completionHandler 
 : 
 ^ 
 ( 
 GADInterstitialAd 
  
 * 
 ad 
 , 
  
 NSError 
  
 * 
 error 
 ) 
  
 { 
  
 if 
  
 ( 
 error 
 ) 
  
 { 
  
 GADResponseInfo 
  
 * 
 responseInfo 
  
 = 
  
 error 
 . 
 userInfo 
 [ 
 GADErrorUserInfoKeyResponseInfo 
 ]; 
  
 NSLog 
 ( 
 @"%@" 
 , 
  
 responseInfo 
 . 
 description 
 ); 
  
 return 
 ; 
  
 } 
  
 GADResponseInfo 
  
 * 
 responseInfo 
  
 = 
  
 ad 
 . 
 responseInfo 
 ; 
  
 NSLog 
 ( 
 @"%@" 
 , 
  
 responseInfo 
 . 
 description 
 ); 
  
 }]; 
 } 

Response info

Here is sample output showing the debugging data returned for a loaded ad:

   
 ** 
  
 Respo 
 nse 
  
 I 
 nf 
 o 
  
 ** 
  
 Respo 
 nse 
  
 ID 
 : 
  
 CLz 
 5 
 r 
 - 
 KM 
 tf 
 oCFQvv 
 7 
 Qod 
 f 
 GAMHw 
  
 Ne 
 t 
 work 
 : 
  
 GADMAdap 
 ter 
 GoogleAdMobAds 
  
 ** 
  
 Loaded 
  
 Adap 
 ter 
  
 Respo 
 nse 
  
 ** 
  
 Ne 
 t 
 work 
 : 
  
 GADMAdap 
 ter 
 GoogleAdMobAds 
  
 Ad 
  
 Source 
  
 Name 
 : 
 Reserva 
 t 
 io 
 n 
  
 campaig 
 n 
  
 Ad 
  
 Source 
  
 ID 
 : 
 7068401028668408324 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 Name 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 ID 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 AdU 
 n 
 i 
 t 
 Mappi 
 n 
 g 
 : 
 { 
 } 
  
 Error 
 : 
  
 ( 
 null 
 ) 
  
 La 
 ten 
 cy 
 : 
  
 0.357 
  
 ** 
  
 Ex 
 tras 
  
 Dic 
 t 
 io 
 nar 
 y 
  
 ** 
  
 { 
  
 "mediation_group_name" 
  
 = 
  
 Campaig 
 n 
 ; 
  
 } 
  
 ** 
  
 Media 
 t 
 io 
 n 
  
 li 
 ne 
  
 i 
 te 
 ms 
  
 ** 
  
 E 
 ntr 
 y 
  
 ( 
 1 
 ) 
  
 Ne 
 t 
 work 
 : 
  
 GADMAdap 
 ter 
 GoogleAdMobAds 
  
 Ad 
  
 Source 
  
 Name 
 : 
 Reserva 
 t 
 io 
 n 
  
 campaig 
 n 
  
 Ad 
  
 Source 
  
 ID 
 : 
 7068401028668408324 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 Name 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 ID 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 AdU 
 n 
 i 
 t 
 Mappi 
 n 
 g 
 : 
 { 
 } 
  
 Error 
 : 
  
 ( 
 null 
 ) 
  
 La 
 ten 
 cy 
 : 
  
 0.357 
 

Properties on GADResponseInfo include:

Property
Description
adNetworkInfoArray
Returns the list of GADAdNetworkResponseInfo 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.

loadedAdNetworkResponseInfo
Returns the GADAdNetworkResponseInfo corresponding to the adapter that loaded the ad.
adNetworkClassName
Returns the mediation adapter class name of the ad network that loaded the ad.
responseIdentifier
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) .
extrasDictionary
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

Swift

 fileprivate 
  
 func 
  
 loadInterstitial 
 () 
  
 { 
  
 InterstitialAd 
 . 
 load 
 ( 
  
 with 
 : 
  
 " ca-app-pub-3940256099942544/4411468910 
" 
 , 
  
 request 
 : 
  
 request 
  
 ) 
  
 { 
  
 ( 
 ad 
 , 
  
 error 
 ) 
  
 in 
  
 let 
  
 responseInfo 
  
 = 
  
 ad 
 ?. 
 responseInfo 
  
 let 
  
 responseIdentifier 
  
 = 
  
 responseInfo 
 ?. 
 responseIdentifier 
  
 let 
  
 adNetworkClassName 
  
 = 
  
 responseInfo 
 ?. 
 adNetworkClassName 
  
 let 
  
 adNetworkInfoArray 
  
 = 
  
 responseInfo 
 ?. 
 adNetworkInfoArray 
  
 let 
  
 loadedAdNetworkResponseInfo 
  
 = 
  
 responseInfo 
 ?. 
 loadedAdNetworkResponseInfo 
  
 let 
  
 mediationGroupName 
  
 = 
  
 responseInfo 
 ?. 
 extrasDictionary 
 [ 
 "mediation_group_name" 
 ] 
  
 let 
  
 mediationABTestName 
  
 = 
  
 responseInfo 
 ?. 
 extrasDictionary 
 [ 
 "mediation_ab_test_name" 
 ] 
  
 let 
  
 mediationABTestVariant 
  
 = 
  
 responseInfo 
 ?. 
 extrasDictionary 
 [ 
 "mediation_ab_test_variant" 
 ] 
  
 } 
 } 

Objective-C

 - 
 ( 
 void 
 ) 
 loadInterstitial 
  
 { 
  
 [ 
 GADInterstitialAd 
  
 loadWithAdUnitID 
 : 
 @" ca-app-pub-3940256099942544/4411468910 
" 
  
 request 
 : 
 request 
  
 completionHandler 
 : 
 ^ 
 ( 
 GADInterstitialAd 
  
 * 
 ad 
 , 
  
 NSError 
  
 * 
 error 
 ) 
  
 { 
  
 GADResponseInfo 
  
 * 
 responseInfo 
  
 = 
  
 ad 
 . 
 responseInfo 
 ; 
  
 NSString 
  
 * 
 responseIdentifier 
  
 = 
  
 responseInfo 
 . 
 responseIdentifier 
 ; 
  
 NSString 
  
 * 
 adNetworkClassName 
  
 = 
  
 responseInfo 
 . 
 adNetworkClassName 
 ; 
  
 NSArray 
  
 * 
 adNetworkInfoArray 
  
 = 
  
 responseInfo 
 . 
 adNetworkInfoArray 
 ; 
  
 GADAdNetworkResponseInfo 
  
 * 
 loadedAdNetworkResponseInfo 
  
 = 
  
 responseInfo 
 . 
 loadedAdNetworkResponseInfo 
 ; 
  
 NSString 
  
 * 
 mediationGroupName 
  
 = 
  
 responseInfo 
 . 
 extrasDictionary 
 [ 
 @"mediation_group_name" 
 ]; 
  
 NSString 
  
 * 
 mediationABTestName 
  
 = 
  
 responseInfo 
 . 
 extrasDictionary 
 [ 
 @"mediation_ab_test_name" 
 ]; 
  
 NSString 
  
 * 
 mediationABTestVariant 
  
 = 
  
 responseInfo 
 . 
 extrasDictionary 
 [ 
 @"mediation_ab_test_variant" 
 ]; 
  
 }]; 
 } 

Adapter Response Info

GADAdNetworkResponseInfo 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 GADAdNetworkResponseInfo output:

   
 Ne 
 t 
 work 
 : 
  
 GADMAdap 
 ter 
 GoogleAdMobAds 
  
 Ad 
  
 Source 
  
 Name 
 : 
 Reserva 
 t 
 io 
 n 
  
 campaig 
 n 
  
 Ad 
  
 Source 
  
 ID 
 : 
 7068401028668408324 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 Name 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 Ad 
  
 Source 
  
 I 
 nstan 
 ce 
  
 ID 
 :[ 
 DO 
  
 NOT 
  
 EDIT 
 ] 
  
 Publisher 
  
 Tes 
 t 
  
 I 
 nterst 
 i 
 t 
 ial 
  
 AdU 
 n 
 i 
 t 
 Mappi 
 n 
 g 
 : 
 { 
 } 
  
 Error 
 : 
  
 ( 
 null 
 ) 
  
 La 
 ten 
 cy 
 : 
  
 0.277 
 

For each ad network, GADAdNetworkResponseInfo provides the following properties:

Property Description
error The error associated with the request to the network. Returns nil if the network successfully loaded an ad or if the network was not attempted.
adSourceId 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 The ad source instance ID associated with this adapter response.
adSourceInstanceName The ad source instance name associated with this adapter response.
adSourceName 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.
adNetworkClassName The class name of the ad network adapter that loaded the ad.
adUnitMapping The network configuration set from the AdMob UI.
latency The amount of time the ad network spent loading an ad. Returns 0 if the network was not attempted.

Swift

 fileprivate 
  
 func 
  
 loadInterstitial 
 () 
  
 { 
  
 InterstitialAd 
 . 
 load 
 ( 
  
 with 
 : 
  
 " ca-app-pub-3940256099942544/4411468910 
" 
 , 
  
 request 
 : 
  
 request 
  
 ) 
  
 { 
  
 ( 
 ad 
 , 
  
 error 
 ) 
  
 in 
  
 let 
  
 responseInfo 
  
 = 
  
 ad 
 ?. 
 responseInfo 
  
 let 
  
 loadedAdNetworkResponseInfo 
  
 = 
  
 responseInfo 
 ?. 
 loadedAdNetworkResponseInfo 
  
 let 
  
 adNetworkError 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 error 
  
 let 
  
 adSourceId 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adSourceID 
  
 let 
  
 adSourceInstanceId 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adSourceInstanceID 
  
 let 
  
 adSourceInstanceName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adSourceInstanceName 
  
 let 
  
 adSourceName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adSourceName 
  
 let 
  
 adNetworkClassName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adNetworkClassName 
  
 let 
  
 adUnitMapping 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 adUnitMapping 
  
 let 
  
 latency 
  
 = 
  
 loadedAdNetworkResponseInfo 
 ?. 
 latency 
  
 } 
 } 

Objective-C

 - 
 ( 
 void 
 ) 
 loadInterstitial 
  
 { 
  
 [ 
 GADInterstitialAd 
  
 loadWithAdUnitID 
 : 
 @" ca-app-pub-3940256099942544/4411468910 
" 
  
 request 
 : 
 request 
  
 completionHandler 
 : 
 ^ 
 ( 
 GADInterstitialAd 
  
 * 
 ad 
 , 
  
 NSError 
  
 * 
 error 
 ) 
  
 { 
  
 GADResponseInfo 
  
 * 
 responseInfo 
  
 = 
  
 ad 
 . 
 responseInfo 
 ; 
  
 GADAdNetworkResponseInfo 
  
 * 
 loadedAdNetworkResponseInfo 
  
 = 
  
 responseInfo 
 . 
 loadedAdNetworkResponseInfo 
 ; 
  
 NSError 
  
 * 
 adNetworkError 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 error 
 ; 
  
 NSString 
  
 * 
 adSourceId 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adSourceID 
 ; 
  
 NSString 
  
 * 
 adSourceInstanceId 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adSourceInstanceID 
 ; 
  
 NSString 
  
 * 
 adSourceInstanceName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adSourceInstanceName 
 ; 
  
 NSString 
  
 * 
 adSourceName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adSourceName 
 ; 
  
 NSString 
  
 * 
 adNetworkClassName 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adNetworkClassName 
 ; 
  
 NSDictionary 
   
 * 
 adUnitMapping 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 adUnitMapping 
 ; 
  
 NSTimeInterval 
  
 latency 
  
 = 
  
 loadedAdNetworkResponseInfo 
 . 
 latency 
 ; 
  
 }]; 
 } 
 
Create a Mobile Website
View Site in Mobile | Classic
Share by: