Skip to main content

GAM and AdMob mediation - Banner (Anchored)


info

This page covers AdMob / GAM mediation. If you integrate Teads directly (no mediator), see the direct integration guide.

This article shows you how to deliver Teads anchored Banner ads on your application using the AdMob adapter or 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.2.0@aar") {
transitive = true
}

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

Defining a Custom Event

In order to display a Teads anchored Banner using AdMob or GAM 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.TeadsAdapter
ParameterJSON string (see below)

GAM

Follow the custom event documentation on GAM using the below values.

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

Custom Event Parameter

The parameter must be a JSON string. The adapter routes to the anchored Banner path as soon as the JSON contains the three required keys (articleUrl, widgetId, installationKey).

ParameterTypeRequiredDescription
articleUrlStringYesThe URL of the article/page
widgetIdStringYesTeads widget ID
installationKeyStringYesTeads installation key
widgetIndexIntNoDefault 0
userIdStringNoPublisher-provided user identifier
extIdStringNoExternal tracking id
extSecondaryIdStringNoSecondary external tracking id
obPubImpStringNoPublisher impression id override
pbfIntNoFloor price in US dollars. Forwarded to the auction as the placement floor price.

For testing purposes, use the following:

{"articleUrl":"https://mobile-demo.outbrain.com/","widgetId":"MB_10","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 and Display the Banner

Add an AdView to your layout, configure it with your AdMob ad unit id and ad size, then call loadAd().

<!-- res/layout/activity_main.xml -->
<FrameLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
warning

Build the AdView with an Activity context (not the application context). Google recommends passing an Activity when initializing ad objects so mediated networks behave consistently, and the Teads banner adapter requires it to size the creative — with an application context the Teads ad fails to load.

import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.AdSize
import com.google.android.gms.ads.AdView

// 2. Build the AdView with a fixed banner size — context MUST be an Activity
val adView = AdView(context).apply {
adUnitId = "YOUR_AD_UNIT_ID" // Ad unit id configured on your Google mediation platform
setAdSize(AdSize.BANNER) // Fixed 320x50dp
}

// 3. Add it to your container and load the ad
findViewById<FrameLayout>(R.id.banner_container).addView(adView)
adView.loadAd(AdRequest.Builder().build())
info

AdSize.BANNER requests a fixed 320x50dp slot from the AdMob waterfall. Use the fixed size, not an adaptive one: adaptive sizes such as AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(...) re-resolve when the view's bounds change (rotation, layout passes), which can trigger duplicate ad requests; the fixed size is invariant. The Teads creative still resizes its own height inside the slot via the JS engine.

Mediation settings

Find the full custom-event JSON parameter list in Settings Configuration — Banner (AdMob Mediation).

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