전면 광고 맞춤 이벤트
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
기본 요건
맞춤 이벤트 설정을 완료합니다.
전면 광고 요청
폭포식 구조 미디에이션 체인에서 맞춤 이벤트 광고 항목에 도달하면 맞춤 이벤트를 만들 때 제공한 클래스 이름에 loadInterstitialAd()
메서드가 호출됩니다. 이 경우 이 메서드는 SampleCustomEvent
에 있고 SampleInterstitialCustomEventLoader
에서 loadInterstitialAd()
메서드를 호출합니다.
전면 광고를 요청하려면 Adapter
를 확장하여 loadInterstitialAd()
를 구현하는 클래스를 만들거나 수정하세요. 또한 MediationInterstitialAd
를 구현할 새 클래스를 만듭니다.
맞춤 이벤트 예에서 SampleCustomEvent
는 Adapter
클래스를 확장한 다음 SampleInterstitialCustomEventLoader
에 위임합니다.
자바
package com.google.ads.mediation.sample.customevent;
import com.google.android.gms.ads.mediation.Adapter;
import com.google.android.gms.ads.mediation.MediationAdConfiguration;
import com.google.android.gms.ads.mediation.MediationAdLoadCallback;
import com.google.android.gms.ads.mediation.MediationInterstitialAd;
import com.google.android.gms.ads.mediation.MediationInterstitialAdCallback;
...
public class SampleCustomEvent extends Adapter {
private SampleInterstitialCustomEventLoader interstitialLoader;
@Override
public void loadInterstitialAd(
@NonNull MediationInterstitialAdConfiguration adConfiguration,
@NonNull
MediationAdLoadCallback<MediationInterstitialAd, MediationInterstitialAdCallback>
callback) {
interstitialLoader = new SampleInterstitialCustomEventLoader(adConfiguration, callback);
interstitialLoader.loadAd();
}
}
SampleInterstitialCustomEventLoader
는 다음 작업을 담당합니다.
전면 광고를 로드하고 로드가 완료되면 MediationAdLoadCallback
메서드 호출
MediationInterstitialAd
인터페이스 구현
Google 모바일 광고 SDK에 광고 이벤트 콜백 수신 및 보고
Ad Manager UI에 정의된 선택적 매개변수는 광고 구성에 포함됩니다. adConfiguration.getServerParameters().getString(MediationConfiguration.CUSTOM_EVENT_SERVER_PARAMETER_FIELD)
를 통해 매개변수에 액세스할 수 있습니다.
이 매개변수는 일반적으로 광고 네트워크 SDK가 광고 객체를 인스턴스화할 때 요구하는 광고 단위 식별자입니다.
자바
package com.google.ads.mediation.sample.customevent;
import com.google.android.gms.ads.mediation.Adapter;
import com.google.android.gms.ads.mediation.MediationInterstitialAdConfiguration;
import com.google.android.gms.ads.mediation.MediationAdLoadCallback;
import com.google.android.gms.ads.mediation.MediationInterstitialAd;
import com.google.android.gms.ads.mediation.MediationInterstitialAdCallback;
...
public class SampleInterstitialCustomEventLoader extends SampleAdListener
implements MediationInterstitialAd {
/** A sample third-party SDK interstitial ad. */
private SampleInterstitial sampleInterstitialAd;
/** Configuration for requesting the interstitial ad from the third-party network. */
private final MediationInterstitialAdConfiguration mediationInterstitialAdConfiguration;
/** Callback for interstitial ad events. */
private MediationInterstitialAdCallback interstitialAdCallback;
/** Callback that fires on loading success or failure. */
private final MediationAdLoadCallback<MediationInterstitialAd, MediationInterstitialAdCallback>
mediationAdLoadCallback;
/** Constructor. */
public SampleInterstitialCustomEventLoader(
@NonNull MediationInterstitialAdConfiguration mediationInterstitialAdConfiguration,
@NonNull MediationAdLoadCallback<MediationInterstitialAd, MediationInterstitialAdCallback>
mediationAdLoadCallback) {
this.mediationInterstitialAdConfiguration = mediationInterstitialAdConfiguration;
this.mediationAdLoadCallback = mediationAdLoadCallback;
}
/** Loads the interstitial ad from the third-party ad network. */
public void loadAd() {
// All custom events have a server parameter named "parameter" that returns
// back the parameter entered into the UI when defining the custom event.
Log.i("InterstitialCustomEvent", "Begin loading interstitial ad.");
String serverParameter = mediationInterstitialAdConfiguration.getServerParameters().getString(
MediationConfiguration.CUSTOM_EVENT_SERVER_PARAMETER_FIELD);
Log.d("InterstitialCustomEvent", "Received server parameter.");
sampleInterstitialAd =
new SampleInterstitial(mediationInterstitialAdConfiguration.getContext());
sampleInterstitialAd.setAdUnit(serverParameter);
// Implement a SampleAdListener and forward callbacks to mediation.
sampleInterstitialAd.setAdListener(this);
// Make an ad request.
Log.i("InterstitialCustomEvent", "start fetching interstitial ad.");
sampleInterstitialAd.fetchAd(
SampleCustomEvent.createSampleRequest(mediationInterstitialAdConfiguration));
}
public SampleAdRequest createSampleRequest(
MediationAdConfiguration mediationAdConfiguration) {
SampleAdRequest request = new SampleAdRequest();
request.setTestMode(mediationAdConfiguration.isTestRequest());
request.setKeywords(mediationAdConfiguration.getMediationExtras().keySet());
return request;
}
}
광고를 성공적으로 가져왔는지 아니면 오류가 발생했는지에 따라 onSuccess()
또는 onFailure()
를 호출합니다.
MediationInterstitialAd
를 구현하는 클래스의 인스턴스를 전달하여 onSuccess()
가 호출됩니다.
일반적으로 이러한 메서드는 어댑터가 구현하는 서드 파티 SDK의 콜백 내에서 구현됩니다. 다음 예시의 샘플 SDK에는 관련 콜백이 있는 SampleAdListener
가 있습니다.
자바
@Override
public void onAdFetchSucceeded() {
interstitialAdCallback = mediationAdLoadCallback.onSuccess(this);
}
@Override
public void onAdFetchFailed(SampleErrorCode errorCode) {
mediationAdLoadCallback.onFailure(SampleCustomEventError.createSampleSdkError(errorCode));
}
MediationInterstitialAd
에서는 광고를 표시하기 위해 showAd()
메서드를 구현해야 합니다.
자바
@Override
public void showAd(@NonNull Context context) {
sampleInterstitialAd.show();
}
onSuccess()
가 호출되면 어댑터가 반환된 MediationInterstitialAdCallback
객체를 사용하여 프레젠테이션 이벤트를 서드 파티 SDK에서 Google 모바일 광고 SDK로 전달할 수 있습니다. SampleInterstitialCustomEventLoader
클래스는 SampleAdListener
인터페이스를 확장하여 샘플 광고 네트워크의 콜백을 Google 모바일 광고 SDK에 전달합니다.
맞춤 이벤트가 이러한 콜백을 최대한 많이 전달하여 앱이 Google 모바일 광고 SDK에서 동등한 이벤트를 수신하도록 하는 것이 중요합니다. 다음은 콜백을 사용하는 방법의 예시입니다.
자바
@Override
public void onAdFullScreen() {
interstitialAdCallback.reportAdImpression();
interstitialAdCallback.onAdOpened();
}
@Override
public void onAdClosed() {
interstitialAdCallback.onAdClosed();
}
전면 광고용 맞춤 이벤트 구현이 완료되었습니다. 전체 예시는 GitHub에서 확인할 수 있습니다.
이미 지원되는 광고 네트워크에 예시를 사용하거나 예시를 수정하여 맞춤 이벤트 전면 광고를 게재할 수도 있습니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eTo request an interstitial ad via a custom event, extend the \u003ccode\u003eAdapter\u003c/code\u003e class and implement the \u003ccode\u003eloadInterstitialAd()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eCreate a separate class that implements \u003ccode\u003eMediationInterstitialAd\u003c/code\u003e to handle ad loading, display, and event reporting.\u003c/p\u003e\n"],["\u003cp\u003eForward ad events like impressions, clicks, and closes from your custom event to the Google Mobile Ads SDK using the \u003ccode\u003eMediationInterstitialAdCallback\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eLeverage the server parameter defined in the Ad Manager UI, often an ad unit ID, to configure your ad requests within the custom event.\u003c/p\u003e\n"],["\u003cp\u003eThe provided sample code demonstrates a complete custom event implementation for interstitial ads, which can be adapted for your specific ad network.\u003c/p\u003e\n"]]],["To request an interstitial ad, create a class extending `Adapter` and implement `loadInterstitialAd()`, and another implementing `MediationInterstitialAd`. In `loadInterstitialAd()`, instantiate a loader class (e.g., `SampleInterstitialCustomEventLoader`) to load the ad and handle callbacks. This loader uses `MediationAdLoadCallback` to report success or failure via `onSuccess()` or `onFailure()`. The `MediationInterstitialAd` must implement a `showAd()` method. The `MediationInterstitialAdCallback` forwards ad events to the Google Mobile Ads SDK.\n"],null,["Prerequisites\n\nComplete the [custom events setup](/ad-manager/mobile-ads-sdk/android/custom-events/setup).\n\nRequest an interstitial ad\n\nWhen the custom event line item is reached in the waterfall mediation chain,\nthe `loadInterstitialAd()` method is called on the class name you provided when\n[creating a custom\nevent](/ad-manager/mobile-ads-sdk/android/custom-events/setup#create). In this case,\nthat method is in `SampleCustomEvent`, which then calls the\n`loadInterstitialAd()` method in `SampleInterstitialCustomEventLoader`.\n\nTo request an interstitial ad, create or modify a class that extends `Adapter`\nto implement `loadInterstitialAd()`. Additionally, create a new class to\nimplement `MediationInterstitialAd`.\n\nIn our [custom event example](//github.com/googleads/googleads-mobile-android-mediation/blob/main/Example/customevent/src/main/java/com/google/ads/mediation/sample/customevent/SampleCustomEvent.java),\n`SampleCustomEvent` extends the `Adapter` class and then delegates to\n`SampleInterstitialCustomEventLoader`. \n\nJava \n\n```java\npackage com.google.ads.mediation.sample.customevent;\n\nimport com.google.android.gms.ads.mediation.Adapter;\nimport com.google.android.gms.ads.mediation.MediationAdConfiguration;\nimport com.google.android.gms.ads.mediation.MediationAdLoadCallback;\nimport com.google.android.gms.ads.mediation.MediationInterstitialAd;\nimport com.google.android.gms.ads.mediation.MediationInterstitialAdCallback;\n...\n\npublic class SampleCustomEvent extends Adapter {\n private SampleInterstitialCustomEventLoader interstitialLoader;\n @Override\n public void loadInterstitialAd(\n @NonNull MediationInterstitialAdConfiguration adConfiguration,\n @NonNull\n MediationAdLoadCallback\u003cMediationInterstitialAd, MediationInterstitialAdCallback\u003e\n callback) {\n interstitialLoader = new SampleInterstitialCustomEventLoader(adConfiguration, callback);\n interstitialLoader.loadAd();\n }\n}\n```\n\n`SampleInterstitialCustomEventLoader` is responsible for the following tasks:\n\n- Loading the interstitial ad and invoking a\n [`MediationAdLoadCallback`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback)\n method once loading completes.\n\n- Implementing the `MediationInterstitialAd` interface.\n\n- Receiving and reporting ad event callbacks to Google Mobile Ads SDK.\n\nThe optional parameter defined in the Ad Manager UI is\nincluded in the ad configuration. The parameter can be accessed through\n`adConfiguration.getServerParameters().getString(MediationConfiguration.CUSTOM_EVENT_SERVER_PARAMETER_FIELD)`.\nThis parameter is typically an ad unit identifier that an ad network SDK\nrequires when instantiating an ad object. \n\nJava \n\n```java\npackage com.google.ads.mediation.sample.customevent;\n\nimport com.google.android.gms.ads.mediation.Adapter;\nimport com.google.android.gms.ads.mediation.MediationInterstitialAdConfiguration;\nimport com.google.android.gms.ads.mediation.MediationAdLoadCallback;\nimport com.google.android.gms.ads.mediation.MediationInterstitialAd;\nimport com.google.android.gms.ads.mediation.MediationInterstitialAdCallback;\n...\n\npublic class SampleInterstitialCustomEventLoader extends SampleAdListener\n implements MediationInterstitialAd {\n\n /** A sample third-party SDK interstitial ad. */\n private SampleInterstitial sampleInterstitialAd;\n\n /** Configuration for requesting the interstitial ad from the third-party network. */\n private final MediationInterstitialAdConfiguration mediationInterstitialAdConfiguration;\n\n /** Callback for interstitial ad events. */\n private MediationInterstitialAdCallback interstitialAdCallback;\n\n /** Callback that fires on loading success or failure. */\n private final MediationAdLoadCallback\u003cMediationInterstitialAd, MediationInterstitialAdCallback\u003e\n mediationAdLoadCallback;\n\n /** Constructor. */\n public SampleInterstitialCustomEventLoader(\n @NonNull MediationInterstitialAdConfiguration mediationInterstitialAdConfiguration,\n @NonNull MediationAdLoadCallback\u003cMediationInterstitialAd, MediationInterstitialAdCallback\u003e\n mediationAdLoadCallback) {\n this.mediationInterstitialAdConfiguration = mediationInterstitialAdConfiguration;\n this.mediationAdLoadCallback = mediationAdLoadCallback;\n }\n\n /** Loads the interstitial ad from the third-party ad network. */\n public void loadAd() {\n // All custom events have a server parameter named \"parameter\" that returns\n // back the parameter entered into the UI when defining the custom event.\n Log.i(\"InterstitialCustomEvent\", \"Begin loading interstitial ad.\");\n String serverParameter = mediationInterstitialAdConfiguration.getServerParameters().getString(\n MediationConfiguration.CUSTOM_EVENT_SERVER_PARAMETER_FIELD);\n Log.d(\"InterstitialCustomEvent\", \"Received server parameter.\");\n\n sampleInterstitialAd =\n new SampleInterstitial(mediationInterstitialAdConfiguration.getContext());\n sampleInterstitialAd.setAdUnit(serverParameter);\n\n // Implement a SampleAdListener and forward callbacks to mediation.\n sampleInterstitialAd.setAdListener(this);\n\n // Make an ad request.\n Log.i(\"InterstitialCustomEvent\", \"start fetching interstitial ad.\");\n sampleInterstitialAd.fetchAd(\n SampleCustomEvent.createSampleRequest(mediationInterstitialAdConfiguration));\n }\n\npublic SampleAdRequest createSampleRequest(\n MediationAdConfiguration mediationAdConfiguration) {\n SampleAdRequest request = new SampleAdRequest();\n request.setTestMode(mediationAdConfiguration.isTestRequest());\n request.setKeywords(mediationAdConfiguration.getMediationExtras().keySet());\n return request;\n }\n}\n```\n\nDepending on whether the ad is successfully fetched or encounters an error, you\nwould call either\n[`onSuccess()`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback#onSuccess(MediationAdT))\nor\n[`onFailure()`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/mediation/MediationAdLoadCallback#onFailure(com.google.android.gms.ads.AdError)).\n`onSuccess()` is called by passing in an instance of the class that implements\n`MediationInterstitialAd`.\n\nTypically, these methods are implemented inside callbacks from the\nthird-party SDK your adapter implements. For this example, the Sample SDK\nhas a `SampleAdListener` with relevant callbacks: \n\nJava \n\n```java\n@Override\npublic void onAdFetchSucceeded() {\n interstitialAdCallback = mediationAdLoadCallback.onSuccess(this);\n}\n\n@Override\npublic void onAdFetchFailed(SampleErrorCode errorCode) {\n mediationAdLoadCallback.onFailure(SampleCustomEventError.createSampleSdkError(errorCode));\n}\n```\n\n`MediationInterstitialAd` requires implementing a `showAd()` method to display\nthe ad: \n\nJava \n\n```java\n@Override\npublic void showAd(@NonNull Context context) {\n sampleInterstitialAd.show();\n}\n```\n\nForward mediation events to Google Mobile Ads SDK\n\nOnce `onSuccess()` is called, the returned `MediationInterstitialAdCallback`\nobject can then be used by the adapter to forward presentation events from the\nthird-party SDK to Google Mobile Ads SDK. The\n`SampleInterstitialCustomEventLoader` class extends the `SampleAdListener`\ninterface to forward callbacks from the sample ad network to the Google Mobile\nAds SDK.\n\nIt's important that your custom event forwards as many of these callbacks as\npossible, so that your app receives these equivalent events from the Google\nMobile Ads SDK. Here's an example of using callbacks: \n\nJava \n\n```java\n@Override\npublic void onAdFullScreen() {\n interstitialAdCallback.reportAdImpression();\n interstitialAdCallback.onAdOpened();\n}\n\n@Override\npublic void onAdClosed() {\n interstitialAdCallback.onAdClosed();\n}\n```\n\nThis completes the custom events implementation for interstitial ads. The full\nexample is available on\n[GitHub](//github.com/googleads/googleads-mobile-android-mediation/tree/master/Example/customevent/src/main/java/com/google/ads/mediation/sample/customevent).\nYou can use it with an ad network that is already supported or modify it to\ndisplay custom event interstitial ads."]]