استرداد المعلومات المتعلقة باستجابة الإعلان

لأغراض تصحيح الأخطاء والتسجيل، توفّر الإعلانات التي تم تحميلها بنجاح عنصر ResponseInfo. يحتوي هذا العنصر على معلومات عن الإعلان الذي تم تحميله، بالإضافة إلى معلومات عن تدفق التوسط المستخدَم لتحميل الإعلان.

في الحالات التي يتم فيها تحميل الإعلان بنجاح، يحتوي عنصر الإعلان على طريقة getResponseInfo() . على سبيل المثال، InterstitialAd.getResponseInfo() يتم الحصول على معلومات الاستجابة لإعلان بيني تم تحميله.

في الحالات التي يتعذّر فيها تحميل الإعلانات ولا يتوفّر سوى خطأ، تكون معلومات الاستجابة متاحة من خلال LoadAdError.getResponseInfo().

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAd)) {
  val responseInfo = interstitialAd.responseInfo
  Log.d(TAG, responseInfo.toString())
}

override fun onAdFailedToLoad(adError: LoadAdError) {
  val responseInfo = adError.responseInfo
  Log.d(TAG, responseInfo.toString())
}

جافا

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  ResponseInfo responseInfo = interstitialAd.getResponseInfo();
  Log.d(TAG, responseInfo.toString());
}

@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
  ResponseInfo responseInfo = loadAdError.getResponseInfo();
  Log.d(TAG, responseInfo.toString());
}

معلومات الردّ

في ما يلي نموذج للنتائج التي تعرضها الدالة ResponseInfo.toString()، والتي توضّح بيانات تصحيح الأخطاء التي يتم عرضها لإعلان تم تحميله:

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

تشمل الطرق في عنصر ResponseInfo ما يلي:

الطريقة الوصف
getAdSourceResponses تعرض قائمة AdSourceResponseInfo التي تحتوي على بيانات وصفية لكل مصدر إعلان مضمّن في استجابة الإعلان. يمكن استخدامها لتصحيح أخطاء تنفيذ عروض الأسعار والتوسّط للعرض الإعلاني بدون انقطاع. يتطابق ترتيب القائمة مع ترتيب تدفق التوسط لطلب عرض الإعلان هذا.

لمزيد من المعلومات، يُرجى الاطّلاع على معلومات استجابة مصدر الإعلان.

getLoadedAdSourceResponse يعرض AdSourceResponseInfo المقابل لمصدر الإعلان الذي حمّل الإعلان.
getAdapterClassName تعرض هذه الطريقة اسم فئة محوّل التوسّط لمصدر الإعلان الذي حمّل الإعلان.
getResponseId معرّف الاستجابة هو معرّف فريد لاستجابة الإعلان. يمكن استخدام هذا المعرّف لتحديد الإعلان وحظره في مركز مراجعة الإعلانات.
getResponseExtras تعرض هذه الدالة معلومات إضافية عن استجابة الإعلان. قد تعرض الإضافات المفاتيح التالية:
  • ‫creative_id: رقم تعريف تصميم الإعلان المحدّد يتم عرضها للإعلانات المحجوزة فقط.
  • ‫line_item_id: معرّف السلعة للإعلان المحدّد يتم عرضها للإعلانات المحجوزة فقط.

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAd) {
  val responseInfo = interstitialAd.responseInfo

  val responseId = responseInfo.responseId
  val adapterClassName = responseInfo.adapterClassName
  val adSourceResponses = responseInfo.adSourceResponses
  val loadedAdSourceResponse = responseInfo.loadedAdSourceResponse
  val extras = responseInfo.responseExtras
  val creativeId = extras.getString("creative_id")
  val lineItemId = extras.getString("line_item_id")
}

جافا

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  MyActivity.this.interstitialAd = interstitialAd;

  ResponseInfo responseInfo = interstitialAd.getResponseInfo();
  String responseId = responseInfo.getResponseId();
  String adapterClassName = responseInfo.getAdapterClassName();
  List<AdSourceResponseInfo> adSourceResponses = responseInfo.getAdSourceResponses();
  AdSourceResponseInfo loadedAdSourceResponse = responseInfo.getLoadedAdSourceResponse();
  Bundle extras = responseInfo.getResponseExtras();
  String creativeId = extras.getString("creative_id");
  String lineItemId = extras.getString("line_item_id");
}

معلومات استجابة مصدر الإعلان

يحتوي AdSourceResponseInfo على معلومات الاستجابة لمصدر إعلان فردي في استجابة الإعلان.

يعرض نموذج ناتج AdSourceResponseInfo التالي البيانات الوصفية لإعلان تم تحميله:

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

بالنسبة إلى كل مصدر إعلان، يوفّر AdSourceResponseInfo الطرق التالية:

الطريقة الوصف
getAdError تحصل على الخطأ المرتبط بالطلب المرسَل إلى مصدر الإعلان. يتم عرض القيمة null إذا حمّل مصدر الإعلان إعلانًا بنجاح أو إذا لم تتم محاولة استخدام مصدر الإعلان.
getId تحصل على رقم تعريف مصدر الإعلان المرتبط باستجابة مصدر الإعلان هذا.
getInstanceId يتم الحصول على رقم تعريف مثيل مصدر الإعلان المرتبط باستجابة المحوّل هذا.
getInstanceName تحصل على اسم مثيل مصدر الإعلان المرتبط باستجابة المحوّل هذه.
getName تحصل على اسم مصدر الإعلان المرتبط باستجابة المحوِّل هذه.
getAdapterClassName تحصل على اسم فئة محوِّل مصدر الإعلان الذي حمّل الإعلان.
getCredentials تحصل على بيانات اعتماد محوّل مصدر الإعلان المحدّدة في واجهة مستخدم "إدارة إعلانات Google".
getLatencyMillis يتم الحصول على مقدار الوقت الذي استغرقه محوّل مصدر الإعلان في تحميل إعلان. يتم عرض القيمة 0 إذا لم تتم محاولة استخدام مصدر الإعلان.

Kotlin

override fun onAdLoaded(interstitialAd: InterstitialAds) {
  val loadedAdSourceResponseInfo = interstitialAd.responseInfo.loadedAdSourceResponse

  val adError = loadedAdSourceResponseInfo.adError
  val adSourceId = loadedAdSourceResponseInfo.id
  val adSourceInstanceId = loadedAdSourceResponseInfo.instanceId
  val adSourceInstanceName = loadedAdSourceResponseInfo.instanceName
  val adSourceName = loadedAdSourceResponseInfo.name
  val adapterClassName = loadedAdSourceResponseInfo.adapterClassName
  val credentials = loadedAdSourceResponseInfo.credentials
  val latencyMillis = loadedAdSourceResponseInfo.latencyMillis
}

جافا

@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
  AdSourceResponseInfo loadedAdSourceResponseInfo =
      interstitialAd.getResponseInfo().getLoadedAdSourceResponse();

  AdError adError = loadedAdSourceResponseInfo.getAdError();
  String adSourceId = loadedAdSourceResponseInfo.getId();
  String adSourceInstanceId = loadedAdSourceResponseInfo.getInstanceId();
  String adSourceInstanceName = loadedAdSourceResponseInfo.getInstanceName();
  String adSourceName = loadedAdSourceResponseInfo.getName();
  String adapterClassName = loadedAdSourceResponseInfo.getAdapterClassName();
  Bundle credentials = loadedAdSourceResponseInfo.getCredentials();
  long latencyMillis = loadedAdSourceResponseInfo.getLatencyMillis();
}