Einrichtung
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Mit benutzerdefinierten Ereignissen können Sie die abfolgebasierte Vermittlung für ein Werbenetzwerk hinzufügen, das nicht von AdMob unterstützt wird. Dazu müssen Sie einen benutzerdefinierten Ereignisadapter für das Werbenetzwerk implementieren, das Sie einbinden möchten.
Vorbereitung
Bevor Sie benutzerdefinierte Ereignisse erstellen können, müssen Sie eines der folgenden Anzeigenformate in Ihre App einbinden:
Benutzerdefiniertes Ereignis in der Benutzeroberfläche erstellen
Ein benutzerdefiniertes Ereignis muss zuerst in der Ad Manager-Benutzeroberfläche erstellt werden. Eine Anleitung dazu finden Sie unter Ertragsgruppen erstellen und verwalten.
Sie müssen Folgendes angeben:
- Klassenname
Der vollständig qualifizierte Name der Klasse, die den benutzerdefinierten Ereignisadapter implementiert, z. B. com.google.ads.mediation.sample.customevent.SampleCustomEvent
. Als Best Practice empfehlen wir, für alle benutzerdefinierten Anzeigenformate für Ereignisse eine einzelne Adapterklasse zu verwenden.
- Label
Ein eindeutiger Name, der die Anzeigenquelle definiert.
- Parameter
Ein optionales String-Argument, das an Ihren benutzerdefinierten Ereignisadapter übergeben wird.
Adapter initialisieren
Wenn das Google Mobile Ads SDK initialisiert wird,
initialize()
wird für alle unterstützten Drittanbieter-Adapter und benutzerdefinierten Ereignisse aufgerufen, die für die App in der Ad Manager-Benutzeroberfläche konfiguriert sind. Verwenden Sie diese Methode, um die erforderliche Einrichtung oder Initialisierung des erforderlichen Drittanbieter-SDK für Ihr benutzerdefiniertes Ereignis vorzunehmen.
Java
package com.google.ads.mediation.sample.customevent;
import com.google.android.gms.ads.mediation.Adapter;
import com.google.android.gms.ads.mediation.InitializationCompleteCallback;
import com.google.android.gms.ads.mediation.MediationConfiguration;
public class SampleAdNetworkCustomEvent extends Adapter {
private static final String SAMPLE_AD_UNIT_KEY = "parameter";
@Override
public void initialize(Context context,
InitializationCompleteCallback initializationCompleteCallback,
List<MediationConfiguration> mediationConfigurations) {
// This is where you will initialize the SDK that this custom
// event is built for. Upon finishing the SDK initialization,
// call the completion handler with success.
initializationCompleteCallback.onInitializationSucceeded();
}
}
Kotlin
package com.google.ads.mediation.sample.customevent
import com.google.android.gms.ads.mediation.Adapter
import com.google.android.gms.ads.mediation.InitializationCompleteCallback
import com.google.android.gms.ads.mediation.MediationConfiguration
class SampleCustomEvent : Adapter() {
private val SAMPLE_AD_UNIT_KEY = "parameter"
override fun initialize(
context: Context,
initializationCompleteCallback: InitializationCompleteCallback,
mediationConfigurations: List<MediationConfiguration>
) {
// This is where you will initialize the SDK that this custom
// event is built for. Upon finishing the SDK initialization,
// call the completion handler with success.
initializationCompleteCallback.onInitializationSucceeded()
}
}
Versionsnummern von Berichten
Für alle benutzerdefinierten Ereignisse muss sowohl die Version des benutzerdefinierten Ereignisadapters als auch die Version des Drittanbieter-SDK, mit dem das benutzerdefinierte Ereignis interagiert, an das Google Mobile Ads SDK gemeldet werden. Versionen werden als VersionInfo
-Objekte gemeldet:
Java
package com.google.ads.mediation.sample.customevent;
public class SampleCustomEvent extends Adapter {
@Override
public VersionInfo getVersionInfo() {
String versionString = new VersionInfo(1, 2, 3);
String[] splits = versionString.split("\\.");
if (splits.length >= 4) {
int major = Integer.parseInt(splits[0]);
int minor = Integer.parseInt(splits[1]);
int micro = Integer.parseInt(splits[2]) * 100 + Integer.parseInt(splits[3]);
return new VersionInfo(major, minor, micro);
}
return new VersionInfo(0, 0, 0);
}
@Override
public VersionInfo getSDKVersionInfo() {
String versionString = SampleAdRequest.getSDKVersion();
String[] splits = versionString.split("\\.");
if (splits.length >= 3) {
int major = Integer.parseInt(splits[0]);
int minor = Integer.parseInt(splits[1]);
int micro = Integer.parseInt(splits[2]);
return new VersionInfo(major, minor, micro);
}
return new VersionInfo(0, 0, 0);
}
}
Kotlin
package com.google.ads.mediation.sample.customevent
class SampleCustomEvent : Adapter() {
override fun getVersionInfo(): VersionInfo {
val versionString = VersionInfo(1,2,3).toString()
val splits: List<String> = versionString.split("\\.")
if (splits.count() >= 4) {
val major = splits[0].toInt()
val minor = splits[1].toInt()
val micro = (splits[2].toInt() * 100) + splits[3].toInt()
return VersionInfo(major, minor, micro)
}
return VersionInfo(0, 0, 0)
}
override fun getSDKVersionInfo(): VersionInfo {
val versionString = VersionInfo(1,2,3).toString()
val splits: List<String> = versionString.split("\\.")
if (splits.count() >= 3) {
val major = splits[0].toInt()
val minor = splits[1].toInt()
val micro = splits[2].toInt()
return VersionInfo(major, minor, micro)
}
return VersionInfo(0, 0, 0)
}
}
Anzeigenanfrage senden
Wenn Sie eine Anzeige anfordern möchten, folgen Sie der Anleitung für das jeweilige Anzeigenformat:
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-31 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-08-31 (UTC)."],[[["\u003cp\u003eCustom events enable waterfall mediation for unsupported ad networks by implementing a custom event adapter.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating custom events, you must integrate a supported ad format (Banner, Interstitial, Native, or Rewarded) into your app.\u003c/p\u003e\n"],["\u003cp\u003eA custom event needs to be defined in the Ad Manager UI with a class name, label, and optional parameter.\u003c/p\u003e\n"],["\u003cp\u003eCustom event adapters must report their version and the third-party SDK version to the Google Mobile Ads SDK using \u003ccode\u003eVersionInfo\u003c/code\u003e objects.\u003c/p\u003e\n"],["\u003cp\u003eAd requests are handled differently for each ad format; refer to the specific instructions for Banner, Interstitial, Native, or Rewarded ads.\u003c/p\u003e\n"]]],[],null,["Custom events let you add waterfall mediation for an ad network that isn't a\n[supported ad network](/ad-manager/mobile-ads-sdk/android/choose-networks). You do this by implementing\na custom event adapter for the ad network you want to integrate.\n\nPrerequisites\n\nBefore you can create custom events, you must first integrate one of the\nfollowing ad format into your app:\n\n- [Banner](/ad-manager/mobile-ads-sdk/android/banner)\n- [Interstitial](/ad-manager/mobile-ads-sdk/android/interstitial)\n- [Native](/ad-manager/mobile-ads-sdk/android/native)\n- [Rewarded](/ad-manager/mobile-ads-sdk/android/rewarded)\n\nCreate a custom event in the UI\n\nA custom event must first be created in the Ad Manager\nUI. See the instructions in\n\n[Create and manage yield\ngroups](//support.google.com/admanager/answer/7390828).\n\n\nYou need to supply the following:\n\nClass Name\n\n: The fully-qualified name of the class that implements the custom event\n adapter---for example,\n\n `com.google.ads.mediation.sample.customevent.SampleCustomEvent`. As a best\n practice, we recommend using a single adapter class for all custom event ad\n formats.\n\nLabel\n\n: A unique name defining the ad source.\n\nParameter\n\n: An optional string argument passed to your custom event adapter.\n\nInitialize the adapter\n\nWhen Google Mobile Ads SDK initializes,\n\n`initialize()`\n\nis invoked on all supported third-party adapters and custom events configured\nfor the app within the Ad Manager UI. Use this method to\nperform any necessary setup or initialization on the required third-party SDK\nfor your custom event. \n\nJava \n\n package com.google.ads.mediation.sample.customevent;\n\n import com.google.android.gms.ads.mediation.Adapter;\n import com.google.android.gms.ads.mediation.InitializationCompleteCallback;\n import com.google.android.gms.ads.mediation.MediationConfiguration;\n\n public class SampleAdNetworkCustomEvent extends Adapter {\n private static final String SAMPLE_AD_UNIT_KEY = \"parameter\";\n\n @Override\n public void initialize(Context context,\n InitializationCompleteCallback initializationCompleteCallback,\n List\u003cMediationConfiguration\u003e mediationConfigurations) {\n // This is where you will initialize the SDK that this custom\n // event is built for. Upon finishing the SDK initialization,\n // call the completion handler with success.\n initializationCompleteCallback.onInitializationSucceeded();\n }\n }\n\nKotlin \n\n package com.google.ads.mediation.sample.customevent\n\n import com.google.android.gms.ads.mediation.Adapter\n import com.google.android.gms.ads.mediation.InitializationCompleteCallback\n import com.google.android.gms.ads.mediation.MediationConfiguration\n\n class SampleCustomEvent : Adapter() {\n private val SAMPLE_AD_UNIT_KEY = \"parameter\"\n\n override fun initialize(\n context: Context,\n initializationCompleteCallback: InitializationCompleteCallback,\n mediationConfigurations: List\u003cMediationConfiguration\u003e\n ) {\n // This is where you will initialize the SDK that this custom\n // event is built for. Upon finishing the SDK initialization,\n // call the completion handler with success.\n initializationCompleteCallback.onInitializationSucceeded()\n }\n }\n\nReport version numbers\n\nAll custom events must report to Google Mobile Ads SDK both the version of\nthe custom event adapter itself and the version of the third-party SDK the\ncustom event interfaces with. Versions are reported as\n\n[`VersionInfo`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/VersionInfo)\n\nobjects: \n\nJava \n\n package com.google.ads.mediation.sample.customevent;\n\n public class SampleCustomEvent extends Adapter {\n\n @Override\n public VersionInfo getVersionInfo() {\n String versionString = new VersionInfo(1, 2, 3);\n String[] splits = versionString.split(\"\\\\.\");\n\n if (splits.length \u003e= 4) {\n int major = Integer.parseInt(splits[0]);\n int minor = Integer.parseInt(splits[1]);\n int micro = Integer.parseInt(splits[2]) * 100 + Integer.parseInt(splits[3]);\n return new VersionInfo(major, minor, micro);\n }\n\n return new VersionInfo(0, 0, 0);\n }\n\n @Override\n public VersionInfo getSDKVersionInfo() {\n String versionString = SampleAdRequest.getSDKVersion();\n String[] splits = versionString.split(\"\\\\.\");\n\n if (splits.length \u003e= 3) {\n int major = Integer.parseInt(splits[0]);\n int minor = Integer.parseInt(splits[1]);\n int micro = Integer.parseInt(splits[2]);\n return new VersionInfo(major, minor, micro);\n }\n\n return new VersionInfo(0, 0, 0);\n }\n }\n\nKotlin \n\n package com.google.ads.mediation.sample.customevent\n\n class SampleCustomEvent : Adapter() {\n override fun getVersionInfo(): VersionInfo {\n val versionString = VersionInfo(1,2,3).toString()\n val splits: List\u003cString\u003e = versionString.split(\"\\\\.\")\n\n if (splits.count() \u003e= 4) {\n val major = splits[0].toInt()\n val minor = splits[1].toInt()\n val micro = (splits[2].toInt() * 100) + splits[3].toInt()\n return VersionInfo(major, minor, micro)\n }\n\n return VersionInfo(0, 0, 0)\n }\n\n override fun getSDKVersionInfo(): VersionInfo {\n val versionString = VersionInfo(1,2,3).toString()\n val splits: List\u003cString\u003e = versionString.split(\"\\\\.\")\n\n if (splits.count() \u003e= 3) {\n val major = splits[0].toInt()\n val minor = splits[1].toInt()\n val micro = splits[2].toInt()\n return VersionInfo(major, minor, micro)\n }\n\n return VersionInfo(0, 0, 0)\n }\n }\n\nRequest ad\n\nTo request an ad, refer to the instructions specific to the ad format:\n\n- [Banner](/ad-manager/mobile-ads-sdk/android/custom-events/banner)\n- [Interstitial](/ad-manager/mobile-ads-sdk/android/custom-events/interstitial)\n- [Native](/ad-manager/mobile-ads-sdk/android/custom-events/native)\n- [Rewarded](/ad-manager/mobile-ads-sdk/android/custom-events/rewarded)"]]