Setup
Stay organized with collections
Save and categorize content based on your preferences.
Custom events let you add waterfall mediation for an ad network that isn't a
supported ad network. You do this by implementing
a custom event adapter for the ad network you want to integrate.
You can find a full sample custom event project in our GitHub
repo.
Prerequisites
Before you can create custom events, you must first integrate one of the
following ad format into your app:
Create a custom event in the UI
A custom event must first be created in the AdMob
UI. See the instructions in
Add a custom event.
You need to supply the following:
- Class Name
The fully-qualified name of the class that implements the custom event
adapter—for example,
SampleCustomEvent
; or if your class is implemented in Swift,
MediationExample.SampleCustomEventSwift
.
Target name is required if you have multiple targets in your project or if
the project name is different from the target name. With the target name, it
would look like this: appName_targetName.className
. In addition, remember
to replace any non-alphanumeric characters such as dashes with underscores.
Example.
- Label
A unique name defining the ad source.
- Parameter
An optional string argument passed to your custom event adapter.
The first step to creating a custom event is implementing the
GADMediationAdapter
protocol as shown by the SampleCustomEvent
class
in our example.
It is the responsibility of this class to receive messages from
AdMob and delegate the responsibility of creating
the correct ad format.
Initialize the adapter
When
Google Mobile Ads SDK
initializes,
setUpWithConfiguration:completionHandler:
is invoked on all supported third-party adapters and custom events configured
for the app within the AdMob UI. Use this method to
perform any necessary setup or initialization on the required third-party SDK
for your custom event.
Swift
import GoogleMobileAds
class SampleCustomEvent: NSObject, MediationAdapter {
static func setUpWith(
_ configuration: MediationServerConfiguration,
completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock
) {
// 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.
completionHandler(nil)
}
}
Objective-C
#import "SampleCustomEvent.h"
@implementation SampleCustomEvent
+ (void)setUpWithConfiguration:(nonnull GADMediationServerConfiguration *)configuration
completionHandler:(nonnull GADMediationAdapterSetUpCompletionBlock)completionHandler {
// This is where you initialize the SDK that this custom event is built
// for. Upon finishing the SDK initialization, call the completion handler
// with success.
completionHandler(nil);
}
Report version numbers
All custom events must report to
Google Mobile Ads SDK
both the version of
the custom event adapter itself and the version of the third-party SDK the
custom event interfaces with. Versions are reported as
GADVersionNumber
objects:
Swift
static func adSDKVersion() -> VersionNumber {
let versionComponents = String(SampleSDKVersion).components(
separatedBy: ".")
if versionComponents.count >= 3 {
let majorVersion = Int(versionComponents[0]) ?? 0
let minorVersion = Int(versionComponents[1]) ?? 0
let patchVersion = Int(versionComponents[2]) ?? 0
return VersionNumber(
majorVersion: majorVersion, minorVersion: minorVersion, patchVersion: patchVersion)
}
return VersionNumber()
}
static func adapterVersion() -> VersionNumber {
let versionComponents = String(SampleAdSDK.SampleAdSDKVersionNumber).components(
separatedBy: ".")
var version = VersionNumber()
if versionComponents.count == 4 {
version.majorVersion = Int(versionComponents[0]) ?? 0
version.minorVersion = Int(versionComponents[1]) ?? 0
version.patchVersion = Int(versionComponents[2]) * 100 + Int(versionComponents[3])
}
return version
}
Objective-C
+ (GADVersionNumber)adSDKVersion {
NSArray *versionComponents =
[SampleSDKVersion componentsSeparatedByString:@"."];
GADVersionNumber version = {0};
if (versionComponents.count >= 3) {
version.majorVersion = [versionComponents[0] integerValue];
version.minorVersion = [versionComponents[1] integerValue];
version.patchVersion = [versionComponents[2] integerValue];
}
return version;
}
+ (GADVersionNumber)adapterVersion {
NSArray *versionComponents =
[SampleCustomEventAdapterVersion componentsSeparatedByString:@"."];
GADVersionNumber version = {0};
if (versionComponents.count == 4) {
version.majorVersion = [versionComponents[0] integerValue];
version.minorVersion = [versionComponents[1] integerValue];
version.patchVersion = [versionComponents[2] integerValue] * 100 +
[versionComponents[3] integerValue];
}
return version;
}
Request ad
To request an ad, refer to the instructions specific to the ad format:
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eCustom events allow you to add waterfall mediation for unsupported ad networks by implementing a custom event adapter.\u003c/p\u003e\n"],["\u003cp\u003eBefore creating custom events, you must integrate an ad format (Banner, Interstitial, Native, or Rewarded) into your app.\u003c/p\u003e\n"],["\u003cp\u003eA custom event needs to be defined in the AdMob UI, requiring a Class Name, Label, and optional Parameter.\u003c/p\u003e\n"],["\u003cp\u003eYou must implement the \u003ccode\u003eGADMediationAdapter\u003c/code\u003e protocol to receive messages from AdMob and delegate ad format creation.\u003c/p\u003e\n"],["\u003cp\u003eThe adapter needs to be initialized, report version numbers, and request ads following format-specific instructions.\u003c/p\u003e\n"]]],["Custom events enable adding waterfall mediation for unsupported ad networks by implementing a custom event adapter. First, create the custom event in the AdMob UI, supplying a class name, label, and optional parameter. Implement the `GADMediationAdapter` protocol, including the `setUpWithConfiguration` method for SDK initialization. Report the custom event adapter and third-party SDK versions using `GADVersionNumber`. Finally, refer to ad format-specific instructions to request an ad. This is all handled in a custom event class.\n"],null,["Custom events let you add waterfall mediation for an ad network that isn't a\n[supported ad network](/admob/ios/choose-networks). You do this by implementing\na custom event adapter for the ad network you want to integrate.\n\nYou can find a full sample custom event project in our [GitHub\nrepo](//github.com/googleads/googleads-mobile-android-mediation).\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](/admob/ios/banner)\n- [Interstitial](/admob/ios/interstitial)\n- [Native](/admob/ios/native)\n- [Rewarded](/admob/ios/rewarded)\n\nCreate a custom event in the UI\n\nA custom event must first be created in the AdMob\nUI. See the instructions in\n\n[Add a custom event](//support.google.com/admob/answer/3083407).\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 `SampleCustomEvent`; or if your class is implemented in Swift,\n `MediationExample.SampleCustomEventSwift`.\n\n Target name is required if you have multiple targets in your project or if\n the project name is different from the target name. With the target name, it\n would look like this: `appName_targetName.className`. In addition, remember\n to replace any non-alphanumeric characters such as dashes with underscores.\n [Example](//maximbilan.medium.com/ios-objective-c-project-nsclassfromstring-method-for-swift-classes-dbadb721723).\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\nImplement GADMediationAdapter\n\nThe first step to creating a custom event is implementing the\n`GADMediationAdapter` protocol as shown by the `SampleCustomEvent` class\nin [our example](//github.com/googleads/googleads-mobile-ios-mediation).\n\nIt is the responsibility of this class to receive messages from\nAdMob and delegate the responsibility of creating\nthe correct ad format.\n\nInitialize the adapter\n\nWhen the Google Mobile Ads SDK initializes,\n\n`setUpWithConfiguration:completionHandler:`\n\nis invoked on all supported third-party adapters and custom events configured\nfor the app within the AdMob UI. Use this method to\nperform any necessary setup or initialization on the required third-party SDK\nfor your custom event. \n\nSwift \n\n import GoogleMobileAds\n\n class SampleCustomEvent: NSObject, MediationAdapter {\n\n static func setUpWith(\n _ configuration: MediationServerConfiguration,\n completionHandler: @escaping GADMediationAdapterSetUpCompletionBlock\n ) {\n // This is where you will initialize the SDK that this custom event is built\n // for. Upon finishing the SDK initialization, call the completion handler\n // with success.\n completionHandler(nil)\n }\n }\n\nObjective-C \n\n #import \"SampleCustomEvent.h\"\n\n @implementation SampleCustomEvent\n\n + (void)setUpWithConfiguration:(nonnull GADMediationServerConfiguration *)configuration\n completionHandler:(nonnull GADMediationAdapterSetUpCompletionBlock)completionHandler {\n // This is where you initialize the SDK that this custom event is built\n // for. Upon finishing the SDK initialization, call the completion handler\n // with success.\n completionHandler(nil);\n }\n\nReport version numbers\n\nAll custom events must report to the 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[`GADVersionNumber`](/admob/ios/api/reference/Structs/GADVersionNumber)\n\nobjects: \n\nSwift \n\n static func adSDKVersion() -\u003e VersionNumber {\n let versionComponents = String(SampleSDKVersion).components(\n separatedBy: \".\")\n\n if versionComponents.count \u003e= 3 {\n let majorVersion = Int(versionComponents[0]) ?? 0\n let minorVersion = Int(versionComponents[1]) ?? 0\n let patchVersion = Int(versionComponents[2]) ?? 0\n\n return VersionNumber(\n majorVersion: majorVersion, minorVersion: minorVersion, patchVersion: patchVersion)\n }\n\n return VersionNumber()\n }\n\n static func adapterVersion() -\u003e VersionNumber {\n let versionComponents = String(SampleAdSDK.SampleAdSDKVersionNumber).components(\n separatedBy: \".\")\n var version = VersionNumber()\n if versionComponents.count == 4 {\n version.majorVersion = Int(versionComponents[0]) ?? 0\n version.minorVersion = Int(versionComponents[1]) ?? 0\n version.patchVersion = Int(versionComponents[2]) * 100 + Int(versionComponents[3])\n }\n return version\n }\n\nObjective-C \n\n + (GADVersionNumber)adSDKVersion {\n NSArray *versionComponents =\n [SampleSDKVersion componentsSeparatedByString:@\".\"];\n GADVersionNumber version = {0};\n if (versionComponents.count \u003e= 3) {\n version.majorVersion = [versionComponents[0] integerValue];\n version.minorVersion = [versionComponents[1] integerValue];\n version.patchVersion = [versionComponents[2] integerValue];\n }\n return version;\n }\n\n + (GADVersionNumber)adapterVersion {\n NSArray *versionComponents =\n [SampleCustomEventAdapterVersion componentsSeparatedByString:@\".\"];\n GADVersionNumber version = {0};\n if (versionComponents.count == 4) {\n version.majorVersion = [versionComponents[0] integerValue];\n version.minorVersion = [versionComponents[1] integerValue];\n version.patchVersion = [versionComponents[2] integerValue] * 100 +\n [versionComponents[3] integerValue];\n }\n return version;\n }\n\nRequest ad\n\nTo request an ad, refer to the instructions specific to the ad format:\n\n- [Banner](/admob/ios/custom-events/banner)\n- [Interstitial](/admob/ios/custom-events/interstitial)\n- [Native](/admob/ios/custom-events/native)\n- [Rewarded](/admob/ios/custom-events/rewarded)"]]