基於偵錯和記錄目的,成功載入的廣告會提供 ResponseInfo 物件。這個物件包含所載入廣告的相關資訊,以及用於載入廣告的中介服務刊登序列資訊。
如果廣告成功載入,廣告物件會提供 GetResponseInfo() 方法。舉例來說,InterstitialAd.GetResponseInfo() 會取得已載入插頁式廣告的回應資訊。
如果廣告載入失敗且只出現錯誤,則可透過 AdFailedToLoadEventArgs.LoadAdError.GetResponseInfo() 取得回應資訊。
InterstitialAd ad;
private void RequestInterstitial()
{
    ad = new InterstitialAd("AD_UNIT_ID");
    this.interstitial.OnAdLoaded += OnAdLoaded;
    this.interstitial.OnAdFailedToLoad += HandleOnAdFailedToLoad;
    AdRequest request = new AdRequest.Builder().Build();
    this.interstitial.LoadAd(request);
}
private void OnAdLoaded(object sender, EventArgs args)
{
    ResponseInfo info = ad.GetResponseInfo();
}
private void OnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
    ResponseInfo info = args.LoadAdError.GetResponseInfo();
}
回應資訊
以下是 ResponseInfo.ToString() 傳回的輸出內容範例,指出已載入廣告傳回的偵錯資料:
Android
{
  "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-app-pub-3940256099942544\/9257395921\/cak=no_cache&cadc=8e&caqid=NI3BZfDhGICQtOUP7ayS4Aw"
    },
    "Ad Error": "null"
  },
  "Response Extras": {
    "creative_id": "138471856178",
    "line_item_id": "6707237225",
  }
}
iOS
** Response Info **
    Response ID: BmnCZaSbE_6Mur8P5su8gAY
    Network: GADMAdapterGoogleAdMobAds
  ** Loaded Adapter Response **
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name:AdMob Network
    Ad Source ID:
    Ad Source Instance Name:AdMob (default)
    Ad Source Instance ID:AdMob (default)
    AdUnitMapping:
{
    pubid = "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=b0&caqid=BmnCZZjMEvzpkPIP5cWfQA";
}
    Error: (null)
    Latency: 2.724
  ** Extras Dictionary **
    {
        "creative_id" = "138471856178";
        "line_item_id" = "6707237225";
    }
  ** Mediation line items **
    Entry (1)
    Network: GADMAdapterGoogleAdMobAds
    Ad Source Name:AdMob Network
    Ad Source ID:
    Ad Source Instance Name:AdMob (default)
    Ad Source Instance ID:AdMob (default)
    AdUnitMapping:
{
    pubid = "ca-pub-9939518381636264//21775744923/example/rewarded-interstitial/cak=no_cache&cadc=b0&caqid=BmnCZZjMEvzpkPIP5cWfQA";
}
    Error: (null)
    Latency: 2.724
ResponseInfo 物件的方法包含:
| 方法 | 說明 | 
|---|---|
| GetAdapterResponses | 傳回 AdapterResponseInfo清單,內含廣告回應中各轉接程式的中繼資料,可用來偵錯刊登序列中介服務和出價執行作業。清單順序與該廣告請求的中介服務刊登序列順序一致。詳情請參閱「轉接程式回應資訊」。 | 
| GetLoadedAdapterResponseInfo | 根據載入廣告的轉接程式,傳回其對應的 AdapterResponseInfo。 | 
| GetMediationAdapterClassName | 針對載入廣告的廣告聯播網,傳回該聯播網的中介服務轉接程式類別名稱。 | 
| GetResponseId | 回應 ID 是廣告回應的專屬 ID。您可在廣告審核中心 (ARC) 輸入這個 ID,找出並封鎖特定廣告。 | 
| GetResponseExtras | 此方法可傳回與廣告回應有關的額外資訊。額外項目可以傳回下列鍵值: 
 | 
以下是已載入的 ResponseInfo 讀取值範例:
private void OnAdLoaded(object sender, EventArgs args)
{
  ResponseInfo info = ad.GetResponseInfo();
  string responseId = responseInfo.GetResponseId();
  string mediationAdapterClassName = responseInfo.GetMediationAdapterClassName();
  List<AdapterResponseInfo> adapterResponses = responseInfo.GetAdapterResponses();
  AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.GetLoadedAdapterResponseInfo();
  Dictionary<string, string> extras = responseInfo.GetResponseExtras();
  string creativeId = extras["creative_id"];
  string lineItemId = extras["line_item_id"];
}
轉接程式回應資訊
AdapterResponseInfo 包含廣告回應中每個轉接程式的中繼資料,可用於偵錯刊登序列中介服務和出價執行作業。清單的項目順序會與該廣告請求的中介服務刊登序列順序一致。
以下是 AdapterResponseInfo 傳回的輸出內容範例:
Android
{ "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" }
iOS
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.391
AdapterResponseInfo 為每個廣告聯播網提供下列方法:
| 方法 | 說明 | 
|---|---|
| AdError | 取得與聯播網請求相關聯的錯誤。如果聯播網成功載入廣告或未收到請求,則傳回 null。 | 
| AdSourceId | 取得與這個轉接程式回應相關聯的廣告來源 ID。如果是廣告活動,中介服務廣告的廣告活動目標類型會傳回 6060308706800320801,曝光和點擊目標類型則會傳回7068401028668408324。如需廣告來源 ID 清單,瞭解放送廣告的廣告聯播網可能使用哪些 ID,請參閱「廣告來源」。 | 
| AdSourceInstanceId | 取得與這個轉接程式回應相關聯的廣告來源例項 ID。 | 
| AdSourceInstanceName | 取得與這個轉接程式回應相關聯的廣告來源例項名稱。 | 
| AdSourceName | 針對放送廣告的特定廣告聯播網,取得代表聯播網的廣告來源。如果是廣告活動,中介服務廣告的廣告活動目標類型會傳回 Mediated House Ads,曝光和點擊目標類型則會傳回Reservation Campaign。如需廣告來源名稱清單,瞭解放送廣告的廣告聯播網可能使用哪些名稱,請參閱「廣告來源」。 | 
| AdapterClassName | 取得可識別廣告聯播網的類別名稱。 | 
| AdUnitMapping | 從 AdMob UI 取得聯播網設定。 | 
| LatencyMillis | 取得廣告聯播網載入廣告所花費的時間。若未對廣告聯播網發出請求,則傳回 0。 | 
以下是已載入 AdapterResponseInfo 的讀取值範例:
private void OnAdLoaded(object sender, EventArgs args)
{
  ResponseInfo responseInfo = ad.GetResponseInfo();
  AdapterResponseInfo loadedAdapterResponseInfo = responseInfo.getLoadedAdapterResponseInfo();
  AdError adError = loadedAdapterResponseInfo.AdError;
  string adSourceId = loadedAdapterResponseInfo.AdSourceId;
  string adSourceInstanceId = loadedAdapterResponseInfo.AdSourceInstanceId;
  string adSourceInstanceName = loadedAdapterResponseInfo.AdSourceInstanceName;
  string adSourceName = loadedAdapterResponseInfo.AdSourceName;
  string adapterClassName = loadedAdapterResponseInfo.AdapterClassName;
  Dictionary<string, string> credentials = loadedAdapterResponseInfo.AdUnitMapping;
  long latencyMillis = loadedAdapterResponseInfo.LatencyMillis;
}