Per scopi di debug e registrazione, gli annunci caricati correttamente forniscono un oggetto
GADResponseInfo
. Questo oggetto contiene informazioni sull'annuncio caricato, oltre a informazioni sulla struttura a cascata della mediazione utilizzata per caricare l'annuncio.
Nei casi in cui un annuncio viene caricato correttamente, l'oggetto annuncio ha una proprietà
GADResponseInfo
. Ad esempio,
GADInterstitialAd.responseInfo
recupera le informazioni sulla risposta per un annuncio interstitial caricato.
Nei casi in cui gli annunci non vengano caricati e sia disponibile solo un errore, il valore GADResponseInfo
è disponibile utilizzando la chiave GADErrorUserInfoKeyResponseInfo
nel dizionario userInfo
dell'errore.
Swift
fileprivate func loadInterstitial() { GADInterstitialAd.load( withAdUnitID: "ca-app-pub-3940256099942544/4411468910", request: request ) { (ad, error) in if let error = error { let responseInfo = (error as NSError).userInfo[GADErrorUserInfoKeyResponseInfo] as? GADResponseInfo 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); }]; }
Informazioni sulla risposta
Ecco un output di esempio che mostra i dati di debug restituiti per un annuncio caricato:
** Response Info **
Response ID: CLz5r-KMtfoCFQvv7QodfGAMHw
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.357
** 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.357
Le proprietà su GADResponseInfo
includono:
Proprietà | Descrizione |
---|---|
adNetworkInfoArray |
Restituisce l'elenco di GADAdNetworkResponseInfo
contenenti i metadati per ogni adattatore incluso nella risposta all'annuncio. Può essere utilizzato per eseguire il debug della mediazione con struttura a cascata e dell'esecuzione delle offerte. L'ordine
dell'elenco corrisponde all'ordine della struttura a cascata della mediazione per questa richiesta di annuncio.
Per ulteriori informazioni, consulta Informazioni sulla risposta dell'adattatore. |
loadedAdNetworkResponseInfo |
Restituisce il GADAdNetworkResponseInfo corrispondente all'adattatore
che ha caricato l'annuncio. |
adNetworkClassName |
Restituisce il nome della classe dell'adattatore di mediazione della rete pubblicitaria che ha caricato l'annuncio. |
responseIdentifier |
L'identificatore risposta è un identificatore univoco per la risposta all'annuncio. Questo identificatore può essere utilizzato per identificare e bloccare l'annuncio nel Centro revisione annunci (ARC). |
extrasDictionary |
Restituisce informazioni aggiuntive sulla risposta all'annuncio. Extras può restituire le seguenti chiavi:
|
Swift
fileprivate func loadInterstitial() { GADInterstitialAd.load( withAdUnitID: "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"]; }]; }
Informazioni sulla risposta dell'adattatore
GADAdNetworkResponseInfo
contiene i metadati di ogni adattatore incluso nella risposta all'annuncio che possono essere utilizzati per eseguire il debug della mediazione a cascata e dell'esecuzione delle offerte. L'ordine dell'elenco corrisponde all'ordine della struttura a cascata della mediazione per la richiesta di annuncio.
Ecco un esempio di output GADAdNetworkResponseInfo
:
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.277
Per ogni rete pubblicitaria, GADAdNetworkResponseInfo
fornisce le seguenti proprietà:
Proprietà | Descrizione |
---|---|
error |
L'errore associato alla richiesta alla rete. Restituisce
nil se la rete ha caricato correttamente un annuncio o se non è stato eseguito alcun tentativo con la rete. |
adSourceId |
L'ID origine annuncio associato a questa risposta dell'adattatore.
Per le campagne, viene restituito 6060308706800320801 per un tipo di obiettivo della campagna con annunci con mediazione e 7068401028668408324 per i tipi di obiettivi di impressioni e clic. Consulta la sezione Origini annuncio per un elenco dei possibili ID origine annuncio quando un annuncio viene pubblicato da una rete pubblicitaria. |
adSourceInstanceId |
L'ID istanza dell'origine annuncio associato a questa risposta dell'adattatore. |
adSourceInstanceName |
Il nome dell'istanza dell'origine annuncio associata a questa risposta dell'adattatore. |
adSourceName |
L'origine annuncio che rappresenta la rete pubblicitaria specifica che pubblica
l'impressione. Per le campagne, viene restituito Mediated House Ads per un tipo di obiettivo della campagna con annunci con mediazione e Reservation Campaign per i tipi di obiettivi di impressioni e clic. Consulta Origini annuncio per un elenco dei possibili nomi delle origini annuncio quando un annuncio viene pubblicato da una rete pubblicitaria. |
adNetworkClassName |
Il nome della classe dell'adattatore della rete pubblicitaria che ha caricato l'annuncio. |
adUnitMapping |
La configurazione di rete impostata dall'interfaccia utente di AdMob. |
latency |
Il tempo impiegato dalla rete pubblicitaria per caricare un annuncio. Restituisce
0 se non è stato fatto alcun tentativo di connessione alla rete. |
Swift
fileprivate func loadInterstitial() { GADInterstitialAd.load( withAdUnitID: "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; }]; }