Skip to main content

Google Ad Manager and AdMob mediation - Interstitial


This article shows you how to deliver Teads interstitial ads on your application using the AdMob adapter or Google Ad Manager (GAM) Mediation adapter.

Prerequisites

Installation

Before installing the Teads AdMob adapter, you will need to integrate GoogleMobileAds SDK into your application.

Gradle

project/build.gradle

allprojects {
repositories {
...
maven { url "https://teads.jfrog.io/artifactory/SDKAndroid-maven-prod" }
}
}

app/build.gradle

dependencies {
...
implementation 'com.google.android.gms:play-services-ads:23.6.0' // or higher

// Teads inApp SDK
implementation("tv.teads.sdk.android:sdk:6.x.x@aar") {
transitive = true
}

// Teads Admob Adapter
implementation 'tv.teads.sdk.android:admobadapter:6.x.x'
}

Defining a Custom Event

In order to display a Teads interstitial ad using AdMob or Google Ad Manager mediation, you need to create a custom event.

Admob

Follow the custom event documentation on the AdMob dashboard using the below values.

NameValue
Class Nametv.teads.adapter.admob.TeadsInterstitialAdapter
ParameterJSON string (see below)

Follow the custom event documentation on Google Ad Manager using the below values.

NameValue
Class Nametv.teads.adapter.admob.TeadsInterstitialAdapter
ParameterJSON string (see below)

Custom Event Parameter

The parameter must be a JSON string. For testing purposes, use the following:

{"articleUrl":"https://mobile-demo.outbrain.com","widgetId":"INT_MW_1","installationKey":"NANOWDGT01"}
warning

For production, your articleUrl, widgetId, and installationKey will be unique values provided by your product manager. Contact your local account manager to obtain your production parameters.

Integration

Initialize Google Mobile Ads

Initialize the Google Mobile Ads SDK before loading any ads:

import com.google.android.gms.ads.MobileAds

// 1. Initialize AdMob
MobileAds.initialize(context)

Load, Listen and Show

The full integration follows this flow: create an ad request, load the interstitial, set up fullscreen lifecycle callbacks inside onAdLoaded, then show the ad when ready.

import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.FullScreenContentCallback
import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.interstitial.InterstitialAd
import com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback

var interstitialAd: InterstitialAd? = null

// 2. Create the AdRequest
val adRequest = AdRequest.Builder().build()

// 3. Load the interstitial ad
InterstitialAd.load(
context,
"YOUR_AD_UNIT_ID", // Ad unit id configured on Google mediation platform
adRequest,
object : InterstitialAdLoadCallback() {
override fun onAdLoaded(ad: InterstitialAd) {

// 4. Listen to fullscreen lifecycle events
ad.fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdShowedFullScreenContent() {
// Ad is now visible fullscreen
}

override fun onAdDismissedFullScreenContent() {
// Ad was closed by the user
interstitialAd = null
}

override fun onAdFailedToShowFullScreenContent(error: AdError) {
// Ad failed to display
interstitialAd = null
}

override fun onAdClicked() {
// User clicked the ad
}

override fun onAdImpression() {
// Ad impression recorded
}
}

interstitialAd = ad
}

override fun onAdFailedToLoad(error: LoadAdError) {
interstitialAd = null
}
}
)

Showing the Ad

Once loaded, present the interstitial ad by calling show() with the current Activity:

// 5. Present the ad at a natural transition point in your app
interstitialAd?.show(activity)

Mediation settings

Find the full settings list in the Integration Guide and Settings Configuration

Check list

  • Ensure Brand Safety is enabled
  • Ensure you comply with privacy legal requirements (GDPR/CCPA/GPP)
  • Comply with app-ads.txt
  • Test with different JSON parameter configurations
  • Enable validation mode to ensure key features are working
  • Implement proper error handling
  • Test on different devices and screen sizes