Firebase Analytics for SaaS: The Complete Setup Guide
Learn how to set up Firebase Analytics for your SaaS product. Track user engagement, retention, and product metrics that actually matter for subscription businesses.
KPIStack Team
Firebase Analytics for SaaS: The Complete Setup Guide
Firebase Analytics (now part of Google Analytics for Firebase) is a powerful, free tool for tracking user behavior in your SaaS application. But out of the box, it's designed for consumer apps. Here's how to configure it for SaaS-specific metrics.
Why Firebase Analytics for SaaS?
Advantages:
- Free with generous limits
- Real-time data available
- Cross-platform (web, iOS, Android)
- Integrates with BigQuery for advanced analysis
- User-level data (unlike GA4's sampling)
What You Can Track:
- Daily/Monthly Active Users (DAU/MAU)
- Feature adoption
- User journeys
- Retention cohorts
- Session duration
- Crash-free users
Setting Up Firebase Analytics
Step 1: Create a Firebase Project
1. Go to Firebase Console 2. Click "Create a project" 3. Name it (e.g., "MyApp Production") 4. Enable Google Analytics when prompted
Step 2: Add Firebase to Your App
For Web (Next.js/React):
javascript
// lib/firebase.ts
import { initializeApp } from 'firebase/app';
import { getAnalytics, logEvent } from 'firebase/analytics';const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
};
const app = initializeApp(firebaseConfig);
export const analytics = typeof window !== 'undefined' ? getAnalytics(app) : null;
Step 3: Configure User Properties
Set user properties to segment your analytics:
javascript
import { setUserProperties } from 'firebase/analytics';// After user signs in
function setUserContext(user) {
if (!analytics) return;
setUserProperties(analytics, {
plan_type: user.plan, // 'free', 'pro', 'enterprise'
account_age_days: calculateAccountAge(user.createdAt),
team_size: user.teamSize,
industry: user.industry,
});
}
Essential SaaS Events to Track
Authentication Events
javascript
// Sign up
logEvent(analytics, 'sign_up', {
method: 'email', // or 'google', 'github'
referral_source: getReferralSource(),
});// Sign in
logEvent(analytics, 'login', {
method: 'email',
});
Onboarding Events
javascript
// Track onboarding progress
logEvent(analytics, 'onboarding_step_completed', {
step_number: 1,
step_name: 'create_organization',
time_to_complete_seconds: 45,
});// Track onboarding completion
logEvent(analytics, 'onboarding_completed', {
steps_completed: 4,
total_time_seconds: 180,
skipped_steps: ['invite_team'],
});
Feature Usage Events
javascript
// Track feature usage
logEvent(analytics, 'feature_used', {
feature_name: 'dashboard_export',
feature_category: 'reporting',
trigger: 'button_click', // or 'keyboard_shortcut', 'api'
});// Track feature discovery
logEvent(analytics, 'feature_discovered', {
feature_name: 'alerts',
discovery_source: 'tooltip', // or 'search', 'menu'
});
Subscription Events
javascript
// Plan upgrade
logEvent(analytics, 'upgrade_started', {
from_plan: 'free',
to_plan: 'pro',
trigger: 'limit_reached', // or 'feature_gated', 'pricing_page'
});logEvent(analytics, 'purchase', {
currency: 'USD',
value: 49.00,
items: [{
item_name: 'Pro Plan',
item_category: 'subscription',
price: 49.00,
quantity: 1,
}],
});
// Cancellation
logEvent(analytics, 'cancel_subscription', {
plan: 'pro',
reason: 'too_expensive', // from exit survey
tenure_months: 6,
});
Engagement Events
javascript
// Page views with context
logEvent(analytics, 'page_view', {
page_title: 'Dashboard',
page_location: window.location.href,
engagement_time_msec: getTimeOnPage(),
});// Search usage
logEvent(analytics, 'search', {
search_term: query,
results_count: results.length,
});
Calculating DAU and MAU
Firebase automatically tracks active users, but here's how to ensure accuracy:
What Counts as "Active"?
By default, Firebase counts any app open as "active." For SaaS, you might want stricter criteria.
Option 1: Custom "meaningful engagement" event
javascript
// Only count users who do something meaningful
function trackMeaningfulEngagement() {
logEvent(analytics, 'user_engagement', {
engagement_type: 'meaningful',
});
}// Call this on key actions, not just page loads
Option 2: Use BigQuery for custom DAU
Export to BigQuery and calculate DAU based on specific events.
Retention Cohort Analysis
Firebase provides built-in cohort retention charts:
1. Go to Firebase Console → Analytics → Retention 2. View Day 1, Day 7, Day 30 retention 3. Filter by user property (plan type, signup source)
What to look for:
- Steep drop-off on Day 1 = onboarding problem
- Decline between Day 7-30 = value realization problem
- Stable after Day 30 = healthy product-market fit
Connecting Firebase to KPIStack
KPIStack integrates with Firebase to pull:
- DAU/MAU metrics
- Retention rates
- Session data
- Crash-free user percentage
This gives you Firebase engagement metrics alongside Stripe revenue data—all in one place.
Best Practices
1. Name Events Consistently
Use a naming convention:
feature_usednotFeatureUsedorfeature-used- Include category in event params, not event name
2. Don't Over-Track
Focus on events that inform decisions:
- ✅ Track: Feature adoption, upgrade triggers, churn signals
- ❌ Don't track: Every button click, mouse movements
3. Set User Properties Early
Set properties immediately after sign-in so all events are properly attributed.
4. Test Before Shipping
Use Firebase DebugView to verify events are firing correctly before deploying.
5. Document Your Events
Maintain a tracking plan:
| Event Name | Description | Parameters |
| sign_up | User creates account | method, referral_source |
| feature_used | User uses a feature | feature_name, category |
| upgrade_started | User begins upgrade | from_plan, to_plan |
Getting Started
1. Set up Firebase Analytics in your app 2. Implement the core SaaS events above 3. Connect Firebase to KPIStack 4. See engagement + revenue metrics together
Tags
Start Tracking Your SaaS Metrics Today
Connect your Stripe and Firebase accounts to KPIStack and see all your KPIs in one unified dashboard.
Start Free Trial