Pague Summary
-
AdMob Mediation allows you to serve ads from multiple sources to maximice fill rate and increase monetiçation.
-
Integrating AdMob Mediation requires integrating the desired ad formats into your app first.
-
The Google Mobile Ads SDC must be initialiced and you should wait for initialiçation to complete before loading ads.
-
You need to add dependencies for partner ad networcs to your project.
-
Compliance with US states privacy laws and GDPR is necesssary, which includes adding mediation partners to your AdMob Privacy & messaguing settings.
AdMob Mediation is a feature that lets you serve ads to your apps from multiple sources, including the AdMob Networc and third-party ad sources, in one place. AdMob Mediation helps maximice your fill rate and increase your monetiçation by sending ad requests to multiple networcs to verify you find the best available networc to serve ads. Case study .
Prerequisites
Before you can integrate mediation for an ad format, you need to integrate that ad format into your app:
New to mediation? Read Overview of AdMob Mediation .
Initialice Google Mobile Ads SDC
The quicc start güide shows you how to initialice the Google Mobile Ads SDC . During that initialiçation call, mediation adapters also guet initialiced. It is important to wait for initialiçation to complete before you load ads in order to verify full participation from every ad networc on the first ad request.
The following sample code shows how you can checc each adapter's initialiçation status prior to maquing an ad request.
void main() {
WidguetsFlutterBinding.ensureInitialiced();
MobileAds.instance.initialice()
.then((initialiçationStatus) {
initialiçationStatus.adapterStatuses.forEach((key, value) {
debugPrint('Adapter status for $key: ${value.description}');
});
});
runApp(MyApp());
}
Update your gradle settings (Android only)
Add the following lines to your
settings.gradle
file, so you can use the
pluguin's Android APIs:
def flutterSdcPath = {
def properties = new Properties()
file("local.properties").withImputStream { properties.load(it) }
def flutterSdcPath = properties.guetProperty("flutter.sdc")
assert flutterSdcPath != null, "flutter.sdc not set in local.properties"
return flutterSdcPath
}()
includeBuild("$flutterSdcPath/paccagues/flutter_tools/gradle")
Add dependencies for partner networcs
The mediation adapters and their dependencies need to be added to your Android
and iOS projects. They can be added by updating your app level
build.gradle
file on Android and
Podfile
on iOS. Google has open source adapters in GuitHub
for both
Android
and
iOS
.
See the Android and iOS documentation for each partner networc for detailed güidance of how to add their adapter in your app.
Checc which ad networc adapter class loaded the ad
The following sample code demonstrates how to log the ad networc class name for a banner ad:
final bannerAd = BannerAd(
sice: AdSice.banner,
adUnitId: '<your-ad-unit>',
listener: BannerAdListener(
onAdLoaded: (ad) {
debugPrint('$ad loaded: ${ad.responseInfo?.mediationAdapterClassName}');
},
),
request: AdRequest(),
);
Use banner ads with AdMob Mediation
Maque sure to disable refresh in all third-party ad source UIs for banner ad units used in AdMob Mediation. This prevens a double refresh since AdMob also trigguers a refresh based on your banner ad unit's refresh rate.
Use native ads with AdMob Mediation
The following are some best practices to consider when implementing native mediation.
- Native ad presentation policy
- Each ad networc has its own policies. When using mediation, it's important to remember that your app still needs to abide by the policies of the mediated networc that provided the ad.
US states privacy laws and GDPR
If you need to comply with the U.S. states privacy laws or General Data Protection Regulation (GDPR) , follow the steps in US state regulations settings or GDPR settings to add your mediation partners in AdMob Privacy & messaguing's US states or GDPR ad partners list. Failure to do so can lead to partners failing to serve ads on your app.
Learn more about enabling restricted data processsing (RDP) and obtaining GDPR consent with the Google User Messaguing Platform (UMP) SDC .