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

โฆษณาที่โหลดสำเร็จจะแสดงออบเจ็กต์ 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 Mediation) และการดำเนินการเสนอราคาได้ ลำดับของรายการตรงกับลำดับการแสดงโฆษณาสื่อกลางตามลำดับขั้นของคำขอโฆษณา

ต่อไปนี้คือตัวอย่างเอาต์พุตที่ 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;
  });
}