May 6, 2025
Firebase Setup: Add
firebase_analytics
andfirebase_core
, then initialize Firebase inmain.dart
.Event Logging: Track key actions like taps and purchases using custom or predefined event methods.
Screen Views: Use
FirebaseAnalyticsObserver
orsetCurrentScreen
for consistent screen tracking.User Properties: Assign attributes to users (e.g., tier, region) for audience segmentation.
Debugging Tools: Leverage Firebase DebugView and logging best practices to validate analytics setup.
Best Practices: Use snake_case, avoid long event names, and monitor parameter consistency.
Introduction
Tracking user behavior is vital for data-driven decision making in any mobile app. With firebase analytics integrated into your Flutter app, you can capture custom events, screen views, user properties, and more—all without writing a backend. In this intermediate tutorial, you’ll learn how to set up the Firebase Analytics SDK, log meaningful events, track screen transitions, and leverage advanced tips for debugging and user segmentation.
Setup and Initialization
Before diving into code, ensure you have a Firebase project with Analytics enabled. In your Flutter project, add the firebase_analytics and firebase_core packages to pubspec.yaml:
Run flutter pub get, then configure Firebase in your Android and iOS projects following the official setup guide. In your main.dart, initialize Firebase and instantiate an Analytics object:
Here, FirebaseAnalytics.instance gives you a singleton for all logging operations. The FirebaseAnalyticsObserver automatically tracks screen transitions.
Logging Custom Events
Custom events let you capture the actions that matter most in your app. Whether it’s a button tap, form submission, or purchase, you can track these with firebase analytics tracking calls:
Best practices:
• Use snake_case for event names.
• Limit parameter values to primitives (String, int, double).
• Reuse predefined Analytics events (e.g., FirebaseAnalytics.logPurchase) when possible to leverage built-in reports.
Tracking Screen Views
Screen tracking is essential for funnel analysis and user flow visualization. While the FirebaseAnalyticsObserver logs route names automatically, you can manually log screens to capture finer details:
By calling setCurrentScreen, you override default behavior and ensure the screen view appears under a clear, consistent name in the Analytics dashboard.
Advanced Techniques: User Properties & Debugging
User properties segment your audience based on attributes like subscription tier, preferred category, or region. Set them once per user:
To debug events locally, use the DebugView in the Firebase console. On Android, run:
On iOS, add the -FIRDebugEnabled
flag to your run scheme. Validation tips:
• Use logEvent sparingly to avoid clutter.
• Ensure event names are under 40 characters.
• Monitor the DebugView to verify parameter values immediately.
For advanced funnels, combine custom events with user properties to build nuanced audience segments—ideal for retention and conversion analyses.
Vibe Studio

Vibe Studio, powered by Steve’s advanced AI agents, is a revolutionary no-code, conversational platform that empowers users to quickly and efficiently create full-stack Flutter applications integrated seamlessly with Firebase backend services. Ideal for solo founders, startups, and agile engineering teams, Vibe Studio allows users to visually manage and deploy Flutter apps, greatly accelerating the development process. The intuitive conversational interface simplifies complex development tasks, making app creation accessible even for non-coders.
Conclusion
By integrating firebase analytics into your Flutter apps, you gain insights into user behavior, optimize flows, and make data-driven improvements. This guide covered setup, custom event logging, screen tracking, and advanced techniques like user properties and debugging. With these building blocks, you can construct comprehensive analytics reports tailored to your app’s unique needs.