광고가 로드되거나 로드되지 않으면 ResponseInfo 객체를 검사합니다. 이 객체는 로드된 광고와 요청을 처리하는 데 사용된 연쇄 광고 호출 조정에 대한 메타데이터를 자세히 설명합니다.
광고가 정상적으로 로드되면 광고 인스턴스에 getResponseInfo 메서드가 포함됩니다. 예를 들어 interstitialAd.getResponseInfo 메서드는 로드된 InterstitialAd 객체의 응답 정보를 반환합니다.
광고를 로드하지 못하면 LoadAdError 객체(예: error.responseInfo)에서 선택사항인 responseInfo 속성에 액세스합니다.
응답 정보 객체 검사
ResponseInfo 객체는 광고 요청에서 반환된 진단 세부정보를 제공합니다.
다음 예는 로드된 광고의 응답 정보 출력을 보여줍니다.
Android
{
"responseId": "COOllLGxlPoCFdAx4Aod-Q4A0g",
"responseExtras": {},
"loadedAdSourceResponseInfo": {
"adapterClassName": "com.google.ads.mediation.admob.AdMobAdapter",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
},
"adSourceResponses": [
{
"adapterClassName": "com.google.ads.mediation.admob.AdMobAdapter",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
}
]
}
iOS
{
"responseId": "COOllLGxlPoCFdAx4Aod-Q4A0g",
"responseExtras": {},
"loadedAdSourceResponseInfo": {
"adapterClassName": "GADMAdapterGoogleAdMobAds",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
},
"adSourceResponses": [
{
"adapterClassName": "GADMAdapterGoogleAdMobAds",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
}
]
}
ResponseInfo 객체는 다음 속성을 제공합니다.
| 속성 | 유형 | 설명 |
|---|---|---|
adSourceResponses |
readonly AdSourceResponseInfo[] |
연쇄 광고 호출 조정의 각 광고 소스 시도를 나타내는 AdSourceResponseInfo 객체의 목록입니다. |
loadedAdSourceResponseInfo |
AdSourceResponseInfo | undefined |
광고를 정상적으로 로드한 광고 소스 어댑터의 메타데이터입니다. 광고가 로드되지 않은 경우 이 값은 undefined입니다. |
responseExtras |
Readonly<Record<string, unknown>> |
광고 응답에서 반환하는 추가 메타데이터(예: mediation_group_name 키)입니다. |
responseId |
string |
광고 응답의 고유 식별자입니다. 이 ID를 사용하여 광고 심사 센터 (ARC)에서 차단 광고를 식별합니다. |
광고 소스 응답 정보 읽기
AdSourceResponseInfo 객체는 광고 응답에 포함된 어댑터의 메타데이터를 제공합니다. 이러한 객체는 연쇄 광고 호출 조정에서 각 광고 소스의 호출 순서대로 나열됩니다.
다음 예는 로드된 광고의 광고 소스 응답 정보 출력을 보여줍니다.
Android
{
"adapterClassName": "com.google.ads.mediation.admob.AdMobAdapter",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
}
iOS
{
"adapterClassName": "GADMAdapterGoogleAdMobAds",
"latencyMillis": 328,
"name": "Reservation campaign",
"id": "7068401028668408324",
"instanceName": "[DO NOT EDIT] Publisher Test Interstitial",
"instanceId": "4665218928925097",
"credentials": {},
"mediationAdError": null
}
AdSourceResponseInfo는 각 광고 소스에 대해 다음 속성을 제공합니다.
| 속성 | 유형 | 설명 |
|---|---|---|
adapterClassName |
string |
광고 네트워크 어댑터의 클래스 이름입니다. |
credentials |
Readonly<Record<string, string>> |
이 어댑터의 AdMob UI에서 구성된 서버 측 매개변수입니다. |
id |
string |
광고 소스의 고유 ID입니다. |
instanceId |
string |
광고 소스 인스턴스의 고유 ID입니다. |
instanceName |
string |
광고 소스 인스턴스의 이름입니다. |
latencyMillis |
number |
네트워크 시도에 걸린 시간(밀리초)입니다. |
mediationAdError |
MediationAdError | undefined |
네트워크 시도가 실패한 경우 이 속성은 오류를 설명합니다. 성공하면 이 값은 undefined입니다. |
name |
string |
광고 소스의 이름입니다(예: "Reservation campaign"). |
전체 응답 정보 로깅
이 섹션에서는 로드된 광고의 전체 응답 정보를 검사하는 구현을 설명합니다.
다음 예에서는 광고가 로드되거나 로드되지 않을 때 응답 정보를 로깅하고 검사합니다.
import {InterstitialAd, LoadAdError} from '@google/mobile-ads';
import type {AdSourceResponseInfo, ResponseInfo} from '@google/mobile-ads';
export async function logResponseInfo(adUnitId: string): Promise<void> {
try {
const interstitial = await InterstitialAd.load({adUnitId});
const responseInfo: ResponseInfo = interstitial.getResponseInfo();
console.log('Ad Loaded Response ID:', responseInfo.responseId);
console.log(
'Loaded Adapter Class Name:',
responseInfo.loadedAdSourceResponseInfo?.adapterClassName,
);
// Inspect each ad source response in the mediation waterfall
responseInfo.adSourceResponses.forEach(
(adSourceResponse: AdSourceResponseInfo, index: number) => {
console.log(
`Waterfall index ${index}:`,
adSourceResponse.adapterClassName,
`Latency: ${adSourceResponse.latencyMillis}ms`,
adSourceResponse.mediationAdError
? `Error: ${adSourceResponse.mediationAdError.message}`
: 'Success',
);
},
);
} catch (error) {
if (error instanceof LoadAdError) {
console.error('Ad failed to load:', error.message);
if (error.responseInfo) {
console.log('Failed Response ID:', error.responseInfo.responseId);
}
}
}
}