<br />

This quickstart guide is for publishers and developers who want to useAdMobto monetize an app that's built with Firebase. If you don't plan to include Firebase in your app, visit the[standaloneAdMobguide](https://developers.google.com/admob/android/quick-start)instead.

If you haven't yet, learn about all the[benefits](https://firebase.google.com/docs/admob/analytics-and-firebase)of usingAdMob, Firebase, andGoogle Analyticstogether.

## Before you begin

- If you don't already have a Firebase project and a Firebase app, follow the Firebase getting started guide:[Add Firebase to your Android project](https://firebase.google.com/docs/android/setup).

- Make sure thatGoogle Analyticsis enabled in your Firebase project:

  - If you're creating a new Firebase project, enableGoogle Analyticsduring the project creation workflow.

  - If you have an existing Firebase project that doesn't haveGoogle Analyticsenabled, you can enableGoogle Analyticsfrom the[*Integrations*](https://console.firebase.google.com/project/_/settings/integrations)tab of yoursettings\>*Project settings*.

  | **Note:** Adding the Firebase SDK forGoogle Analyticsto your app is optional but strongly recommended. Learn more about the[benefits of adding the Firebase SDK forGoogle Analytics](https://firebase.google.com/docs/admob/analytics-and-firebase).

## **Step 1:** Set up your app in yourAdMobaccount

1. Register your app as anAdMobapp.

   1. [Sign into](https://admob.google.com/home/)or[sign up](https://support.google.com/admob/answer/7356219)for anAdMobaccount.

   2. [Register your app withAdMob](https://support.google.com/admob/answer/2773509). This step creates anAdMobapp with a unique[AdMobApp ID](https://support.google.com/admob/answer/7356431)that you'll need later in this guide.

   You'll be asked to add theMobile AdsSDK to your app. Find detailed instructions for this task later in this guide.
2. Link yourAdMobapp to your Firebase app.

   This step is optional but strongly recommended. Learn more about the[benefits](https://firebase.google.com/docs/admob/analytics-and-firebase)of enabling user metrics and linking yourAdMobapp to Firebase.

   Complete the following two steps in the*Apps* dashboard of yourAdMobaccount:
   1. [Enable*User Metrics*](https://support.google.com/admob/answer/9263723)to allowAdMobto process and display curated analytics data in yourAdMobaccount. It's also a required setting for you to link yourAdMobapp to Firebase.

   2. [Link yourAdMobapp](https://support.google.com/admob/answer/6383165)to your existing Firebase project and Firebase app.

      Make sure that you enter the same package name as you entered for your Firebase app. Find your Firebase app's package name in the*Your apps* card of yoursettings\>[*Project settings*](https://console.firebase.google.com/project/_/settings/general).

## **Step 2:** Add yourAdMobApp ID to your`AndroidManifest.xml`file

Add your[AdMobApp ID](https://support.google.com/admob/answer/7356431)to your app's`AndroidManifest.xml`file by adding the`<meta-data>`tag as shown below.
**Important:** This step is required as ofGoogle Mobile AdsSDK v17.0.0. If you don't add this`<meta-data>`tag, your app will crash with the message:`"The `Google Mobile Ads` SDK was initialized incorrectly."`  

```scdoc
<manifest>
    <application>
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.<var translate="no">APPLICATION_ID</var>"
            android:value="<var translate="no">ADMOB_APP_ID</var>"/>
    </application>
</manifest>
```

## **Step 3:** Add and initialize theMobile AdsSDK

1. Add the dependency for theGoogle Mobile AdsSDK to your**module (app-level)** Gradle file (usually`<project>/<app-module>/build.gradle.kts`or`<project>/<app-module>/build.gradle`):

       implementation("com.google.android.gms:play-services-ads:24.8.0")

2. Before loading ads, call the[`MobileAds.initialize()`](https://developers.google.com/android/reference/com/google/android/gms/ads/MobileAds#initialize(android.content.Context))method.

   This call initializes the SDK and calls back a completion listener once initialization is complete (or after a 30-second timeout). Call this method only once and as early as possible, ideally at app launch.
   | **Warning:** Ads may be preloaded by theMobile AdsSDK or mediation partner SDKs upon calling`MobileAds.initialize()`. If you need to take any action before loading ads, make sure that you do so before initializing theMobile AdsSDK. Here are some examples of actions that might be needed prior to initialization:
   | - Obtain consent from users in the European Economic Area (EEA)
   | - Set any request-specific flags (such as`tagForChildDirectedTreatment`or`tag_for_under_age_of_consent`)
   |
   | Learn more in the[AdMobdocumentation](https://developers.google.com/admob/android/eu-consent).

   Here's an example of how to call the`initialize()`method in an Activity:  

   ### Kotlin

   ```kotlin
   override fun onCreate(savedInstanceState: Bundle?) {
       super.onCreate(savedInstanceState)
       // ...
       MobileAds.initialize(this)
   }https://github.com/firebase/snippets-android/blob/294e0edf389e04ad85622081afb988aed37c20fb/admob/app/src/main/java/com/google/firebase/example/admob/kotlin/MainActivity.kt#L10-L14
   ```

   ### Java

   ```java
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       // ...
       MobileAds.initialize(this);
   }https://github.com/firebase/snippets-android/blob/294e0edf389e04ad85622081afb988aed37c20fb/admob/app/src/main/java/com/google/firebase/example/admob/MainActivity.java#L12-L17
   ```

## **Step 4:**View user metrics and analytics data

After its initialization, theMobile AdsSDK automatically starts logging analytics[events](https://support.google.com/admob/answer/9755157)and[user properties](https://support.google.com/admob/answer/9755590)from your app. You can view this data without adding any additional code to your app or implementing any ads. Here's where you can see this analytics data:

- In the*User metrics* card of yourAdMobaccount (*Home* or*Apps* dashboard), you can view curated[user metrics](https://support.google.com/admob/answer/9281746)derived from the collected analytics data, like average session duration,, and retention.

- In the[*Analytics*dashboard](https://console.firebase.google.com/project/_/analytics/)of theFirebaseconsole, you can view aggregated statistics and[summaries of key metrics](https://support.google.com/firebase/answer/6317517). If you[add the Firebase SDK forGoogle Analytics](https://firebase.google.com/docs/admob/analytics-and-firebase), you can also[mark conversions for ad campaigns](https://support.google.com/analytics/answer/9267568)and[build custom audiences](https://support.google.com/analytics/answer/9267572)in theFirebaseconsole.

Note that to better representandmetrics, you might want to include data from an analytics*custom* event called[`ecommerce_purchase`](https://support.google.com/firebase/answer/6317517#revenue)in the revenue calculation for these metrics ([learn how](https://firebase.google.com/docs/admob/analytics-and-firebase#arpu-and-arppu)).
| Data typically appears within an hour but can take up to 48 hours to appear.

## **Step 5:** *(Optional)* Use more features ofGoogle Analyticsand Firebase

Take advantage of more opportunities and features to improve app monetization and user engagement:

- **Add and use the Firebase SDK forGoogle Analytics**

  - Implement[custom event logging](https://firebase.google.com/docs/analytics/events?platform=android)in your app.

  - Mark conversions for[custom ad campaigns](https://support.google.com/firebase/answer/6317518#custom).

  - [Include`ecommerce_purchase`event data](https://firebase.google.com/docs/admob/analytics-and-firebase#arpu-and-arppu)in the revenue calculation forandmetrics.

  To learn more, visit the guide for[usingGoogle Analyticsand Firebase withAdMobapps](https://firebase.google.com/docs/admob/analytics-and-firebase).
- **Use other Firebase products in your app**

  After you add the Firebase SDK forGoogle Analytics, use other Firebase products to optimize ads in your app.
  - [Remote Config](https://firebase.google.com/docs/remote-config)enables you to change the behavior and appearance of your app without publishing an app update, at no cost, for unlimited daily active users.

  - [A/B Testing](https://firebase.google.com/docs/ab-testing)gives you the power to test changes to your app's UI, features, or engagement campaigns to learn if they make an impact on your key metrics (like revenue and retention) before rolling the changes out widely.

<!-- -->

- **Optimize ad monetization for your app**

  Try out different ad formats or configurations with a small subset of users, and then make data driven decisions about implementing the ad for all your users. To learn more, check out the following tutorials:
  - *Test new ad format adoption* ([overview](https://firebase.google.com/docs/tutorials/admob_test-new-ad-format-adoption_solution-overview)\|[implementation](https://firebase.google.com/docs/tutorials/admob_test-new-ad-format-adoption_implementation-guide)).

  - *Optimize ad frequency* ([overview](https://firebase.google.com/docs/tutorials/optimize-ad-frequency/solution-overview)\|[implementation](https://firebase.google.com/docs/tutorials/optimize-ad-frequency)).

## **Step 6:**Choose an ad format to implement in your app

AdMob offers a number of different ad formats, so you can choose the format that best fits the user experience of your app. Click a button for an ad format to view detailed implementation instructions in theAdMobdocumentation.

### Banner

![](https://developers.google.com/admob/images/format-banner.svg)

Rectangular ads that appear at the top or bottom of the device screen

Banner ads stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.  
[Implement Banner Ads](https://developers.google.com/admob/android/banner)

### Interstitial

![](https://developers.google.com/admob/images/format-interstitial.svg)

Full-screen ads that cover the interface of an app until closed by the user

Interstitial ads are best used at natural pauses in the flow of an app's execution, such as between levels of a game or just after a task is completed.  
[Implement Interstitial Ads](https://developers.google.com/admob/android/interstitial)

### Native

![](https://developers.google.com/admob/images/format-native.svg)

Customizable ads that match the look and feel of your app

Native ads are a component-based ad format. You decide how and where Native ads are placed so that the layout is more consistent with your app's design. By choosing fonts, colors, and other details for yourself, you can create natural, unobtrusive ad presentations that can add to a rich user experience.  
[Implement Native Advanced Ads](https://developers.google.com/admob/android/native-advanced)

### Rewarded

![](https://developers.google.com/admob/images/format-rewarded.svg)

Ads that reward users for watching short videos and interacting with playable ads and surveys

Rewarded (or "reward-based") ads can help monetize free-to-play users.  

|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
| [Implement Rewarded Ads](https://firebase.google.com/docs/admob/android/rewarded-video) | [Implement Rewarded Ads (New APIs)](https://firebase.google.com/docs/admob/android/rewarded-ads) |