Firebase Tutorial
- Home
- Introduction
- Project Setup
- Authentication (Email/Pass)
- Social Authentication
- Cloud Firestore (Basics)
- Firestore Queries
- Real-time Updates
- Firestore Security Rules
- Cloud Storage
- Storage Security Rules
- Cloud Functions (Intro)
- Triggering Functions
- Firebase Hosting
- Firebase Analytics
- Crashlytics & Performance
- Remote Config
- App Check
- Offline Persistence
- Firebase with Next.js
- Best Practices
Firebase Analytics
Google Analytics for Firebase provides free, unlimited reporting on up to 500 distinct events. It's the heart of Firebase's growth and engagement features.
1. Basic Logging
Firebase automatically logs many events, but you can also log custom events for specific user actions.
import { getAnalytics, logEvent } from "firebase/analytics";
const analytics = getAnalytics();
// Log a custom event
logEvent(analytics, 'tutorial_completed', {
tutorial_name: 'Firebase Intro',
difficulty: 'Beginner'
});2. Tracking User Properties
User properties allow you to segment your users by fixed attributes like language, favorite genre, or loyalty level.
import { setUserProperties } from "firebase/analytics";
setUserProperties(analytics, { favorite_color: 'blue' });3. DebugView
While developing, you can see your events in real-time in the Firebase Console under the "DebugView" tab.
Privacy Note: Always ensure you are compliant with local data privacy laws (like GDPR) when collecting analytics data.