Truy xuất thông tin về nội dung phản hồi quảng cáo

Đối với mục đích gỡ lỗi và ghi nhật ký, quảng cáo đã tải thành công cung cấp Đối tượng ResponseInfo. Đối tượng này chứa thông tin về quảng cáo mà nó đã tải ngoài thông tin về quy trình dàn xếp kiểu thác nước được dùng để tải quảng cáo.

Đối với trường hợp quảng cáo tải thành công, đối tượng quảng cáo có GetResponseInfo(). Ví dụ: interstitialAd.GetResponseInfo() nhận thông tin phản hồi cho một quảng cáo xen kẽ đã tải.

Phản hồi đối với trường hợp quảng cáo không tải được và chỉ có một lỗi thông tin được cung cấp qua LoadAdError.GetResponseInfo().

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        ResponseInfo errorInfo = error.GetResponseInfo();
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo loadInfo = insterstitialAd.GetResponseInfo();
  });
}

Thông tin phản hồi

Dưới đây là kết quả mẫu do ResponseInfo.ToString() trả về cho thấy dữ liệu gỡ lỗi được trả về cho một quảng cáo đã tải:

Android

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

iOS

 ** Response Info **
    Response ID: CIzs0ZO5kPoCFRqWAAAdJMINpQ
    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.391

  ** 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.391

Các phương thức trên đối tượng ResponseInfo bao gồm:

Phương thức Mô tả
GetAdapterResponses Trả về danh sách AdapterResponseInfo chứa siêu dữ liệu cho mỗi bộ chuyển đổi có trong nội dung phản hồi quảng cáo. Có thể dùng để gỡ lỗi dàn xếp kiểu thác nước và đặt giá thầu. Thứ tự của danh sách khớp với thứ tự dàn xếp kiểu thác nước cho yêu cầu quảng cáo này.

Hãy xem bài viết Thông tin về phản hồi của bộ chuyển đổi để biết thêm thông tin của bạn.

GetLoadedAdapterResponseInfo Trả về AdapterResponseInfo tương ứng với trình chuyển đổi đã tải quảng cáo.
GetMediationAdapterClassName Trả về tên lớp bộ chuyển đổi dàn xếp của mạng quảng cáo đã tải quảng cáo.
GetResponseId Giá trị nhận dạng nội dung phản hồi là giá trị nhận dạng riêng biệt của nội dung phản hồi quảng cáo. Chiến dịch này mã nhận dạng có thể được sử dụng để xác định và chặn quảng cáo trong Trung tâm xem xét quảng cáo (ARC).
GetResponseExtras Trả về thông tin bổ sung về nội dung phản hồi quảng cáo. Ứng dụng khác có thể trả về các khoá sau:
  • mediation_group_name: Tên nhóm dàn xếp
  • mediation_ab_test_name: Tên của thử nghiệm A/B dàn xếp, nếu có
  • mediation_ab_test_variant: Biến thể được sử dụng trong thử nghiệm A/B dàn xếp, nếu có

Dưới đây là ví dụ về các giá trị đọc của một ResponseInfo đã tải:

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo responseInfo = insterstitialAd.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 mediationGroupName = extras["mediation_group_name"];
    string mediationABTestName = extras["mediation_ab_test_name"];
    string mediationABTestVariant = extras["mediation_ab_test_variant"]; 
  });
}

Thông tin phản hồi của bộ chuyển đổi

AdapterResponseInfo chứa siêu dữ liệu cho từng bộ chuyển đổi có trong quảng cáo Nội dung phản hồi này. Bạn có thể dùng nội dung này để gỡ lỗi quy trình dàn xếp kiểu thác nước và đặt giá thầu thực thi chính sách. Thứ tự của danh sách này khớp với thứ tự của quy trình dàn xếp kiểu thác nước cho yêu cầu quảng cáo.

Dưới đây là kết quả mẫu do AdapterResponseInfo trả về:

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

Đối với mỗi mạng quảng cáo, AdapterResponseInfo cung cấp các phương thức sau:

Phương thức Mô tả
AdError Xem lỗi liên quan đến yêu cầu gửi đến mạng. Trả lại hàng null nếu mạng đã tải quảng cáo thành công hoặc nếu chưa thử mạng.
AdSourceId Xem mã nguồn quảng cáo liên kết với nội dung phản hồi của bộ chuyển đổi này. Đối với chiến dịch, 6060308706800320801 được trả về cho quảng cáo đã dàn xếp loại mục tiêu chiến dịch, và 7068401028668408324 được trả về cho lượt hiển thị và lượt nhấp mục tiêu. Hãy xem bài viết Nguồn quảng cáo để biết danh sách mã nguồn quảng cáo có thể có khi một mạng quảng cáo phân phát quảng cáo.
AdSourceInstanceId Xem mã bản sao nguồn quảng cáo liên kết với bộ chuyển đổi này của bạn.
AdSourceInstanceName Xem tên phiên bản nguồn quảng cáo liên kết với bộ chuyển đổi này của bạn.
AdSourceName Xem nguồn quảng cáo đại diện cho mạng quảng cáo cụ thể phân phát lần hiển thị. Đối với chiến dịch, Mediated House Ads được trả về cho quảng cáo đã dàn xếp loại mục tiêu chiến dịch, và Reservation Campaign được trả về cho lượt hiển thị và lượt nhấp mục tiêu. Hãy xem bài viết Nguồn quảng cáo để biết danh sách tên nguồn quảng cáo có thể có khi một mạng quảng cáo phân phát quảng cáo.
AdapterClassName Lấy tên lớp xác định mạng quảng cáo.
AdUnitMapping Lấy cấu hình mạng được đặt từ giao diện người dùng AdMob.
LatencyMillis Xem lượng thời gian cần để mạng quảng cáo tải quảng cáo. Trả về 0 nếu mạng chưa thử tải quảng cáo.

Dưới đây là ví dụ về các giá trị đọc của một AdapterResponseInfo đã tải:

private void LoadInterstitialAd()
{
  AdRequest adRequest = new AdRequest();
  InterstitialAd.Load("AD_UNIT_ID", adRequest, (InterstitialAd insterstitialAd, LoadAdError error) =>
  {
    // If the operation failed with a reason.
    if (error != null)
    {
        Debug.LogError("Interstitial ad failed to load an ad with error : " + error);
        return;
    }

    ResponseInfo responseInfo = insterstitialAd.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;
  });
}