How to Integrate Google Analytics in Android App

Cody Schneider8 min read

Adding Google Analytics to your Android app is one of the best ways to understand exactly how people are using it, where they get stuck, and what features they love most. This guide will walk you through the entire process, step by step, using the modern and recommended approach that connects your app's performance directly to comprehensive analytics reports.

First, Why Bother with Analytics in Your Android App?

Diving into development, it's easy to focus solely on features and bug fixes. But without data, you’re flying blind. Analytics data acts as your co-pilot, giving you the real-world feedback needed to build a better app and a stronger business. Here’s what you gain:

  • Understand User Behavior: See which screens users spend the most time on, the paths they take through your app, and where they tend to drop off. This insight helps you identify popular features to enhance and confusing workflows to simplify.
  • Improve User Experience (UX): Are users struggling with a new feature? Are load times causing them to leave? Analytics can highlight friction points in the user journey, allowing you to make targeted improvements that boost satisfaction and retention.
  • Measure What Matters (Conversions): Track key actions, such as in-app purchases, sign-ups, or level completions. By measuring these conversions, you can directly link your development efforts and marketing campaigns to tangible business outcomes.
  • Smart, Data-Driven Decisions: Instead of guessing what users want, you can base your roadmap on actual behavior. Data can help you prioritize new features, optimize marketing spend, and allocate resources where they’ll have the biggest impact.

The Most Important Change: It’s All About Firebase Now

If you’ve searched for how to add Google Analytics to an Android app before, you might have found older tutorials that sound completely different from this one. That's because the landscape has changed significantly.

Previously, Google had separate SDKs (Software Development Kits) for mobile analytics. Today, Google Analytics 4 is deeply integrated with Firebase, Google’s comprehensive platform for building and growing apps. The modern, official, and most powerful way to get Google Analytics into your app is by using the Google Analytics for Firebase SDK.

Think of it this way: Firebase provides the tools to get the data out of your app, and Google Analytics 4 provides the robust reporting interface to analyze that data. They are designed to work together, so you will be setting them both up in the following steps.

What You’ll Need Before You Start

Let's get a few things lined up to make this process smooth. You'll need:

  • An existing Android app project in Android Studio.
  • A Google account to create and access your Firebase project and Google Analytics account.
  • Basic familiarity with Android Studio and the Gradle build system.

Step-by-Step Guide to Integrating Google Analytics in Your App

We'll walk through this one piece at a time. By the end, your app will be sending data right into your analytics dashboard.

Step 1: Create a Firebase Project and Connect Your App

First, we need to introduce your app to Firebase. This creates a bridge for data to start flowing.

  1. Go to the Firebase Console and sign in with your Google account.
  2. Click on "Add project". Give your project a name (e.g., "My Awesome App Analytics").
  3. On the next screen, you’ll be prompted to set up Google Analytics for your project. This is exactly what we want, so make sure it's enabled and click "Continue".
  4. Choose an existing Google Analytics account or create a new one. Accept the terms and click "Create project".
  5. Once your project is ready, you'll land on the project dashboard. Click the Android icon (the little robot) to add your Android app.
  6. You'll be asked for your app's package name. You can find this in your project’s build.gradle (Module: app) file, under the applicationId value. Enter it and give your app a nickname.
  7. Click "Register app".
  8. Now, you'll be prompted to Download google-services.json. This file is extremely important as it contains all the configuration details linking your app to your Firebase project. Download it and save it somewhere secure for the next step.

Step 2: Add the google-services.json File to Your Project

Now, let's put that key configuration file where it belongs.

Switch over to Android Studio. Make sure you are in the "Project" view (you can change this from the dropdown at the top of the project files pane). Navigate to your app directory. Place the google-services.json file you just downloaded directly inside your app-level directory (e.g., MyAwesomeApp/app/).

Step 3: Add the Firebase and Google Analytics SDKs with Gradle

With the config file in place, we need to tell our app's build system to include the necessary libraries.

You'll need to edit two different build.gradle files.

1. Project-level build.gradle (yourproject/build.gradle)

Add the Google services plugin to your dependencies:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        // ... other dependencies
        classpath 'com.google.gms:google-services:4.4.1'
    }
}

2. App-level build.gradle (yourproject/app/build.gradle)

First, apply the plugin at the top of the file, right after any other plugins.

plugins {
    id 'com.android.application'
    // ... possibly other plugins like kotlin-android
    id 'com.google.gms.google-services' // Add this line
}

Next, inside the dependencies block, add the Firebase Bill of Materials (BOM). This is the recommended way to manage Firebase library versions. It ensures that all your Firebase dependencies use compatible versions. Then add the dependency for Google Analytics itself.

dependencies {
    // ...other dependencies

    // Import the Firebase BoM
    implementation(platform("com.google.firebase:firebase-bom:32.7.2"))

    // Add the dependency for the Google Analytics library
    implementation("com.google.firebase:firebase-analytics")
}

After adding these, Android Studio will show a bar at the top asking you to "Sync Now". Click it to have Gradle download and add the new libraries to your project.

How to Start Tracking Events and User Properties

Your setup is complete! By simply including the SDK, Google Analytics automatically starts collecting some data, like screen views and basic user engagement metrics. But the real power comes from tracking actions and attributes specific to your app.

Tracking Custom Events

An "event" is any meaningful action a user takes in your app. This could be tapping a button, sharing content, or completing a tutorial. Firebase has some predefined event names, or you can create your own.

To start tracking, get an instance of the FirebaseAnalytics class in your Activity or Fragment.

For example, to log an event when a user shares a piece of content, you can do this (Kotlin example):

import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase

private lateinit var firebaseAnalytics: FirebaseAnalytics

// In your onCreate() method or wherever you initialize things:
firebaseAnalytics = Firebase.analytics

// When the user performs the action:
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SHARE) {
    param(FirebaseAnalytics.Param.ITEM_ID, "article_42")
    param(FirebaseAnalytics.Param.CONTENT_TYPE, "article")
}

Here, we logged a standard "SHARE" event and added parameters to provide more context: the specific ID of the item being shared and its type.

Setting User Properties

User properties are attributes you define to describe segments of your user base. For example, you could track a user’s subscription level, favorite game genre, or preferred language. This helps you understand how different types of users behave.

To set a user property, use the setUserProperty() method.

// For example, after a user selects their favorite food in settings:
firebaseAnalytics.setUserProperty("favorite_food", "pizza")

This property will be associated with the user from this point forward, allowing you to segment your analytics reports based on who loves pizza.

Verifying Your Analytics Integration with DebugView

You don't want to wait 24 hours just to see if your new events are being tracked correctly. The Firebase DebugView lets you see your app's event data in real-time, which is fantastic for testing.

To enable it for your development device:

  1. Connect your Android device via USB or use an emulator.
  2. Open a terminal in Android Studio or your computer's command line.
  3. Run the following command (replace your.package.name with your app's actual package name):
adb shell setprop debug.firebase.analytics.app your.package.name

Now, run your app. In the Firebase Console, go to "DebugView" under the Analytics section. As you use your app and trigger your custom events, you will see them appear in the debug console within seconds. Once you've confirmed it's working, you can disable debug mode with:

adb shell setprop debug.firebase.analytics.app .none.

That's it! Your Android app is now equipped with powerful analytics to guide your decisions.

Final Thoughts

Integrating Google Analytics into your Android app using the Firebase SDK is the modern standard for collecting vital user behavior data. By logging specific events and user properties, you move beyond guesswork and start making strategic, data-informed decisions that truly improve your app experience.

Of course, once your data is flowing into Google Analytics, the next challenge is turning it into easy-to-understand insights. Instead of spending hours buried in analytics reports, we built Graphed to do the heavy lifting for you. By connecting your Google Analytics account, you can simply ask questions in plain English, like "Show me a chart of daily active users this month" or "Which in-app events are most popular?", and get instant, real-time dashboards that your entire team can understand.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.