How To Add Firebase Analytics To Android

Step 1: Add Firebase To Android.

Edit module/app build.gradle.

dependencies {
    implementation ''

NOTE: is a recommended alias for the library.

Once you included, Firebase Analytics automatically track all activty view event (you don't have to write any code).

If you need to log custom events

val analytics = FirebaseAnalytics.getInstance(this)val bundle = Bundle();bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id)bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name)bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image")analytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle)

NOTE: I have yet to deeper than activity event logging, so refer to Firebase Analytics Doc for more info.

Disable Analytics For Debug Build

I believe Firebase Analytics is enabled by default, even for Debug build.

To disable analytics for Debug build, edit app/module build.gradle.

android {
    // ...
    buildTypes {
        debug {
            // manifestPlaceholders = [crashlyticsEnabled: false, analyticsEnabled: false]
            manifestPlaceholders = [analyticsEnabled: false]
        release {
            manifestPlaceholders = [analyticsEnabled: true]
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

Edit AndroidManifest.xml.

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <application ...>
            android:value="${analyticsEnabled}" />



Firebase Analytics Report

To retrieve the Analytics report, goto Firebase Console, select project, click Analytics -> Dashboard from the left panel.

Active Users are recorded by default.

Firebase Analytics Dashboard

Activity/Screen engagement are recorded by default.

Firebase Analytics Activity

Basic Events are recorded by default.

Firebase Analytics Events


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.