> ## Documentation Index
> Fetch the complete documentation index at: https://docs.median.co/llms.txt
> Use this file to discover all available pages before exploring further.

# AdMob native ads

> Show Google AdMob banner and interstitial ads in your app, and handle iOS tracking consent and GDPR consent with the JavaScript Bridge.

Monetize your mobile app and gain analytics with Google AdMob, Google's mobile advertising platform. This guide explains how to integrate AdMob using the Median JavaScript Bridge, including setup, banner and interstitial ad formats, user consent for tracking, and GDPR compliance.

> [!TIP]
>
> **Test  with our demo page**
>
> We host a ready-made demo page at
>
> that calls the  features through the Median JavaScript Bridge.
> Load it inside your Median app during development, either by setting it
> as your app's website URL in App Studio or by navigating to it from your
> own site, and use it to confirm  works on a real device before
> you add it to your own pages.
>
> The demo page only works inside a Median app with  enabled.
> Opened in a regular mobile or desktop browser, the native features
> won't respond. Remember to switch your app back to your own URL before
> release.

## What is AdMob?

Google AdMob enables mobile app developers to earn revenue by displaying native banner ads and interstitial ads. These ad formats offer a better user experience and higher monetization potential compared to traditional website-based ads.

The AdMob Native Ads SDK, when integrated with your app via the JavaScript Bridge, gives you access to the platform’s features, including advanced ad rendering and user tracking consent management.

## Supported ad formats

AdMob supports two primary ad types:

* **Banner ads:** Displayed persistently near the bottom of the app window, below your web content. Ideal for passive monetization without interrupting user experience.
* **Interstitial ads:** Full-screen ads that appear at natural breaks in your app flow (e.g., after completing a level or before loading a new page). These ads may include video, animation, or timers and are more visually engaging, but should be used thoughtfully due to their interruptive nature.

| Banner Ad | Interstitial Ad |
| :-: | :-: |
| ![AdMob banner ad below the web content](https://mintcdn.com/median-co/yvThAkXSLqPa6nzP/images/docs/docs/admob/admob-banner.png?fit=max\&auto=format\&n=yvThAkXSLqPa6nzP\&q=85\&s=83740e051ac7c3f74e909021f98f57fe) | ![Full-screen AdMob interstitial ad](https://mintcdn.com/median-co/yvThAkXSLqPa6nzP/images/docs/docs/admob/admob-interstitial.png?fit=max\&auto=format\&n=yvThAkXSLqPa6nzP\&q=85\&s=63cad7dbef561bfb2554f035f8e0d887) |

## Implementation guide

### Enabling the module

In order to configure the AdMob module for your app, you will need to provide the AdMob Application ID and the Interstitial Ad Unit ID and/or Banner Ad Unit ID for both Android and iOS. Create ad units for a banner ad and an interstitial ad. If the Interstitial Ad Unit ID or Banner Ad Unit ID is not provided, then the respective ad type will not be shown.

> [!NOTE]
>
> **Banner ad display when no ads available**
>
> Android will only display a banner ad if there is an ad available. iOS will display a blank area for the banner if there is no ad available.

There are separate unit identifiers for Android and iOS because AdMob considers them to be two separate apps.

To disable automatically showing the banner ad when the app loads, set **AdMob Banner Ad Enabled** to **Disable**. You may then show it programmatically at runtime (see the JavaScript Bridge command below).

> [!WARNING]
>
> **ATT required for iOS**
>
> Make sure to enable App Tracking Transparency (ATT) on the **Permissions** tab to ensure AdMob functions correctly on iOS.

### Show interstitial ads

Interstitial ads are not shown automatically. They are pre-loaded in the background and must be invoked at runtime.

To show an interstitial ad, run the following JavaScript function:

Median JavaScript Bridge

```javascript JavaScript  theme={null}
median.admob.showInterstitialIfReady(); 
```

> Note: This should be done when the user is at a natural pausing point, for example when they tap something to initiate an action, or they have finished viewing a piece of content. Note that interstitial ad fill rates are significantly lower than banner ads, and there may not always be an interstitial ad ready. In that case, no interstitial will be shown.
>
> Alternatively, trigger the ad, if available, on the next page navigation:

Median JavaScript Bridge

```javascript JavaScript theme={null}
median.admob.showInterstitialOnNextPageLoadIfReady();
```

### Control banner ad display

To enable/disable displaying banner ads, run the following commands. If **AdMob Banner Ad Enabled** is set to **Disable** you must run the enable command to begin showing the banner.

Enable or disable banner ads with these commands:

Median JavaScript Bridge

```javascript JavaScript theme={null}
median.admob.banner.enable(); // Show banner
median.admob.banner.disable(); // Hide banner
```

### iOS 14+ tracking consent (IDFA)

iOS 14 requires user consent for applications to use the IDFA (Identifier for Advertisers). Given consent, AdMob will use IDFA, otherwise it will fall back to less targeted identifiers. In all cases App Tracking Transparency (ATT) must be enabled on the Permissions tab.

Enable ATT and prompt the user with the following commands:

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Using a callback
median.admob.request.tracking({ callback: trackingCallback });

function trackingCallback(result) {
  if (result.status === 'authorized') {
    console.log('Thank you for enabling personalized ads');
  }
}

// Using a promise
median.admob.request.tracking().then(function(result) {
  if (result.status === 'authorized') {
    console.log('Thank you for enabling personalized ads');
  }
});
```

`callback` is an optional parameter to get the result of the user decision. It should be the name of a JavaScript function that will receive the result. The result will be an object with a status string, which can be "authorized", "denied", or "restricted" (denied by corporate policy or user is underage).

### GDPR and user consent

AdMob now requires certain disclosures to your users in the European Economic Area (EEA) along with the UK and obtain their consent to use cookies or other local storage, where legally required, and to use personal data (such as AdID) to serve ads.

Create a user message in your AdMob console under **Privacy & Messaging**, then prompt users with:

Median JavaScript Bridge

```javascript JavaScript theme={null}
// Callback method
median.admob.request.consent({ callback: consentCallback });

function consentCallback(result) {
  if (result.success === true) {
    console.log('Thank you for enabling personalized ads');
  }
}

// Promise method
median.admob.request.consent().then(function(result) {
  if (result.success === true) {
    console.log('Thank you for enabling personalized ads');
  }
});
```

`callback` is an optional parameter to get the result of the user decision. It should be the name of a JavaScript function that will receive the result. The result will be an object with a `result` boolean.


## Related topics

- [Integrations](https://docs.median.co/docs/integrations.md)
- [Changelog archive](https://docs.median.co/docs/changelog-archive.md)
- [Changelog](https://docs.median.co/docs/changelog.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.