ดึงข้อมูลเกี่ยวกับการตอบกลับของโฆษณา

โฆษณาที่โหลดสำเร็จจะแสดง ออบเจ็กต์ ResponseInfo รายการ ออบเจ็กต์นี้มีข้อมูลเกี่ยวกับโฆษณาที่โหลด นอกเหนือจากข้อมูลเกี่ยวกับ Waterfall ของสื่อกลางที่ใช้โหลดโฆษณา

ในกรณีที่โฆษณาโหลดสำเร็จ ออบเจ็กต์โฆษณาจะมี GetResponseInfo() วิธี เช่น interstitialAd.GetResponseInfo() รับข้อมูลการตอบกลับสำหรับโฆษณาคั่นระหว่างหน้าที่โหลด

ในกรณีที่โฆษณาโหลดไม่สำเร็จและแสดงเฉพาะข้อผิดพลาด มีข้อมูลผ่าน 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();
  });
}

ข้อมูลการตอบกลับ

ต่อไปนี้เป็นตัวอย่างเอาต์พุตที่ ResponseInfo.ToString() แสดงผลโดยแสดง ข้อมูลการแก้ไขข้อบกพร่องที่แสดงผลสำหรับโฆษณาที่โหลด:

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

เมธอดในออบเจ็กต์ ResponseInfo มีดังนี้

วิธีการ คำอธิบาย
GetAdapterResponses แสดงรายการ AdapterResponseInfo ที่มีข้อมูลเมตา สำหรับอะแดปเตอร์แต่ละรายการที่รวมอยู่ในการตอบกลับโฆษณา สามารถใช้เพื่อแก้ไขข้อบกพร่อง การแสดงโฆษณาสื่อกลางตามลำดับขั้น (Waterfall Mediation) และการดำเนินการเสนอราคา ลำดับของรายการตรงกับ ลำดับการแสดงโฆษณาสื่อกลางตามลำดับขั้นสำหรับคำขอโฆษณานี้

ดูข้อมูลเพิ่มเติมในข้อมูลการตอบสนองของอะแดปเตอร์

GetLoadedAdapterResponseInfo แสดง AdapterResponseInfo ที่สอดคล้องกับอะแดปเตอร์ ที่โหลดโฆษณา
GetMediationAdapterClassName แสดงชื่อคลาสอะแดปเตอร์สื่อกลางของเครือข่ายโฆษณาที่โหลด โฆษณา
GetResponseId ตัวระบุการตอบกลับคือตัวระบุที่ไม่ซ้ำสำหรับการตอบกลับโฆษณา ช่วงเวลานี้ จะใช้เพื่อระบุและบล็อกโฆษณาในศูนย์ตรวจสอบโฆษณา (ARC) ได้
GetResponseExtras แสดงข้อมูลเพิ่มเติมเกี่ยวกับการตอบกลับโฆษณา ส่วนขยายสามารถแสดงผล คีย์ต่อไปนี้
  • mediation_group_name: ชื่อกลุ่มสื่อกลาง
  • mediation_ab_test_name: ชื่อการทดสอบ A/B สำหรับสื่อกลาง หากมี
  • mediation_ab_test_variant: ตัวแปรที่ใช้ใน การทดสอบ A/B สำหรับสื่อกลาง (หากมี)

ตัวอย่างค่าการอ่านจาก ResponseInfo ที่โหลด

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"]; 
  });
}

ข้อมูลการตอบกลับอะแดปเตอร์

AdapterResponseInfo มีข้อมูลเมตาสำหรับอะแดปเตอร์แต่ละรายการรวมอยู่ในโฆษณา ซึ่งสามารถใช้เพื่อแก้ไขข้อบกพร่องของสื่อกลาง Waterfall และการเสนอราคา ลำดับของรายการตรงกับลำดับของการแสดงโฆษณาสื่อกลางตามลำดับขั้น สำหรับคำขอโฆษณา

ต่อไปนี้คือตัวอย่างเอาต์พุตที่ 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 รับรหัสแหล่งที่มาของโฆษณาที่เชื่อมโยงกับการตอบกลับของอะแดปเตอร์นี้ สำหรับแคมเปญ ส่งกลับ 6060308706800320801 สำหรับโฆษณาที่ใช้สื่อกลาง ประเภทเป้าหมายแคมเปญ และระบบจะส่งคืน 7068401028668408324 สำหรับการแสดงผลและคลิก ประเภทเป้าหมาย ดูแหล่งที่มาของโฆษณา สำหรับรายการรหัสแหล่งที่มาของโฆษณาที่เป็นไปได้เมื่อเครือข่ายโฆษณาแสดงโฆษณา
AdSourceInstanceId รับรหัสอินสแตนซ์ของแหล่งที่มาของโฆษณาที่เชื่อมโยงกับอะแดปเตอร์นี้ คำตอบ
AdSourceInstanceName รับชื่ออินสแตนซ์แหล่งที่มาของโฆษณาที่เชื่อมโยงกับอะแดปเตอร์นี้ คำตอบ
AdSourceName รับแหล่งที่มาของโฆษณาที่แสดงเครือข่ายโฆษณาที่เฉพาะเจาะจงซึ่งแสดงโฆษณา การแสดงผล สำหรับแคมเปญ ส่งกลับ Mediated House Ads สำหรับโฆษณาที่ใช้สื่อกลาง ประเภทเป้าหมายแคมเปญ และระบบจะส่งคืน Reservation Campaign สำหรับการแสดงผลและคลิก ประเภทเป้าหมาย ดูแหล่งที่มาของโฆษณา สำหรับรายการชื่อแหล่งที่มาของโฆษณาที่เป็นไปได้เมื่อเครือข่ายโฆษณาแสดง โฆษณาของคุณ
AdapterClassName รับชื่อคลาสที่ระบุเครือข่ายโฆษณา
AdUnitMapping รับการกำหนดค่าเครือข่ายจาก AdMob UI
LatencyMillis แสดงระยะเวลาที่เครือข่ายโฆษณาใช้ในการโหลดโฆษณา แสดงผล 0 หากไม่มีการพยายามเชื่อมต่อเครือข่าย

ตัวอย่างค่าการอ่านจาก AdapterResponseInfo ที่โหลด

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;
  });
}