Response Info
The NAM SDK provides a GFPLoadResponseInfo object that you can use for debugging and logging when an ad load succeeds or fails. It carries the unique identifier of the ad request (Request ID), the latency of each stage, and a record of which adapters the mediation waterfall tried and in what order.
There are two ways to obtain the response info:
- On load success : the
responseInfoproperty of the loaded ad object - On load failure : the
responseInfoargument delivered through each delegate'sdidFailWithError:responseInfo:callback
How to obtain
| Ad format | On load success | On load failure |
|---|---|---|
| Banner | adLoader:didReceiveBannerAd: → bannerView.responseInfo | adLoader:didFailWithError:responseInfo: |
| Native | adLoader:didReceiveNativeAd: → nativeAd.responseInfo | adLoader:didFailWithError:responseInfo: |
| Native Simple | adLoader:didReceiveNativeSimpleAd: → nativeSimpleAd.responseInfo | adLoader:didFailWithError:responseInfo: |
| Interstitial | interstitialAdManager:didLoadAd: → interstitialAd.responseInfo | interstitialAdManager:didFailWithError:responseInfo: |
| Rewarded | rewardedAdManager:didLoadAd: → rewardedAd.responseInfo | rewardedAdManager:didFailWithError:responseInfo: |
Examples
Using GFPAdLoader
When you use GFPAdLoader, which supports loading banner, native, and native simple ads, you can check the ad response info as shown below.
- Swift
- Objective-C
func adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceiveBannerAd bannerView: GFPBannerView!) {
print("banner ad response info: \(bannerView.responseInfo)")
}
func adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceiveNativeAd nativeAd: GFPNativeAd!) {
print("native ad response info: \(nativeAd.responseInfo)")
}
func adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceiveNativeSimpleAd nativeSimpleAd: GFPNativeSimpleAd!) {
print("native simple ad response info: \(nativeSimpleAd.responseInfo)")
}
func adLoader(_ unifiedAdLoader: GFPAdLoader!, didFailWithError error: GFPError!, responseInfo: GFPLoadResponseInfo!) {
print("on error response info: \(String(describing: responseInfo))")
}
- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didReceiveBannerAd:(GFPBannerView *)bannerView {
NSLog(@"banner ad response info: %@", bannerView.responseInfo);
}
- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didReceiveNativeAd:(GFPNativeAd *)nativeAd {
NSLog(@"native ad response info: %@", nativeAd.responseInfo);
}
- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didReceiveNativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd {
NSLog(@"native simple ad response info: %@", nativeSimpleAd.responseInfo);
}
- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didFailWithError:(GFPError *)error responseInfo:(GFPLoadResponseInfo *)responseInfo {
NSLog(@"on error response info: %@", responseInfo);
}
Using GFPInterstitialAdManager
- Swift
- Objective-C
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didLoadAd interstitialAd: GFPInterstitialAd) {
print("response info: \(interstitialAd.responseInfo)")
}
func interstitialAdManager(_ manager: GFPInterstitialAdManager, didFailWithError error: GFPError, responseInfo: GFPLoadResponseInfo!) {
print("response info: \(String(describing: responseInfo))")
}
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didLoadAd:(nonnull GFPInterstitialAd *)interstitialAd {
NSLog(@"response info: %@", interstitialAd.responseInfo);
}
- (void)interstitialAdManager:(nonnull GFPInterstitialAdManager *)manager didFailWithError:(nonnull GFPError *)error responseInfo:(nullable GFPLoadResponseInfo *)responseInfo {
NSLog(@"response info: %@", responseInfo);
}
Using GFPRewardedAdManager
- Swift
- Objective-C
func rewardedAdManager(_ manager: GFPRewardedAdManager, didLoadAd rewardedAd: GFPRewardedAd) {
print("response info: \(rewardedAd.responseInfo)")
}
func rewardedAdManager(_ manager: GFPRewardedAdManager, didFailWithError error: GFPError, responseInfo: GFPLoadResponseInfo!) {
print("response info: \(String(describing: responseInfo))")
}
- (void)rewardedAdManager:(nonnull GFPRewardedAdManager *)manager didLoadAd:(nonnull GFPRewardedAd *)rewardedAd {
NSLog(@"response info: %@", rewardedAd.responseInfo);
}
- (void)rewardedAdManager:(nonnull GFPRewardedAdManager *)manager didFailWithError:(nonnull GFPError *)error responseInfo:(nullable GFPLoadResponseInfo *)responseInfo {
NSLog(@"response info: %@", responseInfo);
}
Sample log output
Logging GFPLoadResponseInfo as-is lets you inspect the whole mediation waterfall at a glance.
[GFPLoadResponseInfo] requestID: 0f0f1d3c-..., adCallLatency: 0.083, adaptorLoadLatency: 0.402, totalLoadLatency: 0.485, adaptorResponses: (
"[GFPAdaptorResponseInfo] adaptorName: GFPSDKMediationDFP.GFPDFPBannerAdaptor, loadErrorLatency: 0.156, errorMessage: no ad to show",
"[GFPAdaptorResponseInfo] adaptorName: GFPNDABannerAdaptor, loadLatency: 0.246"
)
The example above means the first adapter failed and the ad was then selected from the second adapter.
Response info
The properties of the GFPLoadResponseInfo object include the following.
| Property | Type | Description |
|---|---|---|
| requestID | NSString | The unique identifier for the ad request. It is a useful key for tracking down the cause when a problem occurs on a specific ad request. |
| adCallLatency | NSNumber | The time in seconds it took to send the request to the ad server and receive the response. Returns 0 if no ad was requested or no response was received. |
| adaptorLoadLatency | NSNumber | The time in seconds from the start of the mediation selection process until it finished. This includes the time spent on failed adapter attempts. Returns 0 if mediation did not proceed because no response was received from the ad server. |
| totalLoadLatency | NSNumber | The total time in seconds from sending the request to the ad server until the mediation selection process finished. Returns 0 if no response was received from the ad server. |
| adContext | NSString? | The ad context string of the selected ad. Returns nil if it is not included in the ad response. |
| crid | NSString? | The Creative ID of the selected ad creative. Returns nil if no ad was loaded successfully. |
| loadResponseList | [GFPInternalResponseInfo] | The list of response info for each mediation adapter tried on this ad request. It can be used to debug the waterfall mediation process, and the order of the list matches the mediation call order of this ad request. |
Adapter response info
GFPInternalResponseInfo holds the response info for an individual mediation adapter processed during mediation, and its properties include the following.
| Property | Type | Description |
|---|---|---|
| adaptorName | NSString | The class name of the mediation adapter that identifies the ad network. The value is not set if the attempt failed before the adapter was created. |
| loadLatency | NSNumber | The time in seconds it took to request and load the ad inside the adapter. Returns 0 if no ad was requested inside the adapter or if the ad request failed. |
| loadErrorLatency | NSNumber | The time in seconds from requesting the ad inside the adapter until the error occurred. Returns 0 if no ad was requested inside the adapter or if the ad request succeeded. |
| errorMesage | NSString | The error message that occurred inside the adapter. EMPTY is recorded when the ad response is empty, and no value is set when the ad request succeeded. |
| errorCode | NSNumber? | The code of the error that occurred inside the adapter. Returns nil if no error code was delivered or the ad request succeeded. See Error Codes for details on each code. |
| errorSubcode | NSString? | The sub-code of the error that occurred inside the adapter. Returns nil if no sub-code was delivered or the ad request succeeded. |