How to Connect Flutter with Google Analytics Using Firebase
Want to understand how users interact with your Flutter application? Firebase Analytics makes it simple to connect your app with Google Analytics so you can track user behavior, monitor app performance, and make better product decisions without building your own analytics system.
Introduction
Building a Flutter application is only the beginning of the journey. Once your app reaches users, one of the biggest questions becomes how people actually use it. Which screens do they visit the most? Which features are popular? Where do users leave the app? Answering these questions helps developers improve the user experience instead of relying on assumptions.
This is where Google Analytics, powered by Firebase, becomes extremely useful. Firebase Analytics allows you to collect important information about user activity while keeping the integration simple for Flutter developers. Since Firebase officially supports Flutter, the setup process is straightforward and works across both Android and iOS from a single codebase.
In this blog, we’ll go through the complete process of connecting Flutter with Google Analytics using Firebase, explain why Firebase is recommended, and learn how to track custom events inside your application. The setup described here follows the standard Firebase Analytics integration flow for Flutter.
Why Use Firebase Analytics Instead of Direct Google Analytics?
Google Analytics for mobile apps is designed to work through Firebase. Instead of connecting a Flutter application directly to Google Analytics, Firebase acts as the bridge between your application and Google Analytics 4.
This approach removes most of the complexity involved in analytics integration. Firebase automatically collects several useful events while also allowing developers to track custom actions that are specific to their application.
Because Firebase is maintained by Google, it stays updated with the latest analytics features and provides a stable solution for Flutter applications. It also integrates well with other Firebase services such as Crashlytics, Cloud Messaging, Remote Config, and Performance Monitoring, making it a complete platform for mobile app development.
Creating a Firebase Project
The first step is creating a Firebase project from the Firebase Console.
During project creation, Firebase gives you the option to enable Google Analytics. Once Analytics is enabled, Firebase automatically creates or links a Google Analytics 4 property with your project.
After the project is ready, you simply register your Flutter application by adding your Android package name and iOS bundle identifier. Firebase then provides the required configuration files for each platform, allowing your application to communicate securely with Firebase services.
Registering Flutter Application
Registering the Android App:
Step 1: Open your Firebase project and click Add App.
Step 2: Select the Android icon.
Step 3: Enter your application’s Android Package Name. You can find it in:
android/app/build.gradle
or
android/app/build.gradle.kts
Look for the following value:
applicationId “com.example.myapp”
Step 4: (Optional) Enter an App Nickname and SHA-1 certificate if required.
Step 5: Click Register App.
Step 6: Download the google-services.json file.
Step 7: Copy the downloaded file into your Flutter project at: android/app/google-services.json
Registering the iOS App:
Step 1: In the same Firebase project, click Add App again.
Step 2: Select the iOS icon.
Step 3: Enter your application’s iOS Bundle Identifier. You can find it by opening:ios/Runner.xcodeproj,or by opening the project in Xcode and navigating to:
Runner → Signing & Capabilities → Bundle Identifier
Step 4: (Optional) Enter an App Nickname and App Store ID.
Step 5: Click Register App.
Step 6: Download the GoogleService-Info.plist file.
Step 7: Open the iOS project in Xcode.
Step 8: Drag and drop the GoogleService-Info.plist file into the Runner folder.
Step 9: Make sure Copy items if needed is checked, then click Finish.
Flutter Setup for Google Analytics
Installing Firebase Packages:
firebase_core: ^latest_version
firebase_analytics: ^latest_version
Initializing Firebase:
Open your main.dart file.
void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(const MyApp()); }
Creating the Analytics Instance:
Create a single Analytics instance that can be reused throughout the application.
import ‘package:firebase_analytics/firebase_analytics.dart’;
final FirebaseAnalytics analytics = FirebaseAnalytics.instance;
Tracking Custom Events:
One of the biggest advantages of Firebase Analytics is custom event tracking.
Instead of only knowing how many users opened the app, you can also know exactly what they did inside the application.
Ex: await analytics.logLogin( loginMethod: “email”, );
Tracking Screen Views:
This information helps identify which pages are popular and which screens users leave quickly.
Firebase allows screen tracking very easily.
Ex: await analytics.logScreenView( screenName: “HomeScreen”, );
Setting User ID:
This makes it easier to analyze user journeys without storing personal information directly inside analytics.
If your application has login functionality, you can associate analytics data with a specific user.
ex:await analytics.setUserId( id: userId, );
Testing Analytics Before Release
Before publishing the application, always verify that events are reaching Firebase correctly.
Firebase provides DebugView, which shows analytics events almost instantly while your application is running.
For Android, enable DebugView using ADB.
adb shell setprop debug.firebase.analytics.app your.package.name
After launching the application, open DebugView inside Firebase Console.
Perform actions inside the app.
You should immediately see the events appearing in DebugView.
Testing before release helps ensure that all important events are working correctly.
What Can You Track?
After your application is live, Firebase automatically begins collecting analytics data.
You can monitor application usage through Google Analytics dashboards and Firebase reports.
Some of the most useful insights include active users, screen views, user engagement, countries, devices, retention, custom events, and daily usage trends.
This information helps developers understand how users interact with the application and identify opportunities for improvement.
Common Events You Should Track
Every application is different, but some events are useful in almost every project.
Examples include application launch, user login, account registration, product selection, checkout, payment completion, search activity, profile updates, feature usage, and feedback submission.
Choosing meaningful events allows you to measure the features that matter most to your business rather than collecting unnecessary data.
Conclusion
Firebase Analytics is one of the easiest ways to understand how users interact with a Flutter application. Instead of guessing what users like or dislike, you can make decisions based on real data.
The setup process is straightforward. Create a Firebase project, register your Flutter application, install the required packages, initialize Firebase, and start logging events. Once everything is connected, Google Analytics automatically provides valuable insights into user behavior, engagement, and application performance.
Whether you’re building a small personal project or a large production application, analytics should be part of your development process from the beginning. The earlier you start collecting data, the better you’ll understand your users and the easier it becomes to improve your app over time.