mobile5 min read

Tutorial: Learn Mobile Analytics from Scratch (2026)

Tutorial: Learn Mobile Analytics from Scratch (2026)

Published:  |  Category: Mobile  |  Reading time: ~15 min
Tutorial: Learn Mobile Analytics from Scratch (2026)

Mobile analytics turns raw user behavior data into actionable product insights. Before I implemented proper analytics, I was making product decisions based on intuition and anecdotal feedback from a few vocal users. Analytics provides quantitative data on how users actually behave: which features they use, where they drop off, and what drives retention. Firebase Analytics is the most widely used mobile analytics platform, especially for Android, with Mixpanel, Amplitude, and Segment as popular alternatives. This tutorial covers instrumenting your app with analytics events, building funnels and cohorts, and using data to drive product decisions.

A good analytics strategy starts with defining the key metrics for your app, often called North Star metrics and supporting KPIs. Events capture user actions (screen views, button taps, purchases) and user properties capture attributes (subscription tier, country, device type). Event naming follows conventions like screen_view, button_click, and purchase_complete. User privacy is paramount: GDPR, CCPA, and Apple's App Tracking Transparency require explicit consent for tracking. Always anonymize user identifiers and provide opt-out mechanisms.

Choosing and Setting Up an Analytics Platform

Firebase Analytics is free, integrates seamlessly with other Google services, and works on both iOS and Android. Set up with a Firebase project, add the GoogleService-Info.plist (iOS) or google-services.json (Android), and initialize Firebase in your app. Mixpanel offers advanced segmentation and retention analysis with a generous free tier. Amplitude is strong for behavioral analytics and predictive models. Segment acts as a middleware that forwards events to multiple destinations, making it easy to switch providers. For privacy-focused alternatives, consider Countly or Matomo (self-hosted). All platforms support automatic tracking of screen views, sessions, and app lifecycle events.

// Firebase Analytics initialization (Android)
val firebaseAnalytics = Firebase.analytics
val logParams = bundleOf("item_name" to "shoes", "price" to 59.99)
firebaseAnalytics.logEvent("purchase_complete", logParams)

Event Tracking Strategy and Naming Conventions

Define a tracking plan spreadsheet before coding. Each event has a name, parameters, and trigger condition. Follow naming conventions: verb_noun format (sign_up_completed, item_purchased, level_started). Use snake_case for consistency. Parameters should be typed (string, int, double) and limited in cardinality (avoid high-cardinality values like timestamps as parameter values). Firebase recommends no more than 500 unique event types per project. Track user properties like subscription_tier, onboarding_completed, and preferred_language. Avoid tracking personally identifiable information. Use debug mode during development to verify events with DebugView in Firebase Console.

// Event tracking plan
// Event: purchase_completed
// Params: item_id (string), price (double), currency (string), quantity (int)

Funnels, Cohorts, and Retention Analysis

Funnels analyze sequential steps leading to a conversion event. Common funnels: onboarding completion, add-to-cart to purchase, and sign-up to first action. Firebase Funnels show step-by-step drop-off rates. Cohorts group users by a shared characteristic (sign-up date, acquisition channel) and track behaviors over time. Retention cohorts show whether users return after 1 day, 7 days, and 30 days. Compare retention across different user segments. Mixpanel's formula reports combine events and user properties for custom metrics. Use these insights to identify drop-off points and experiment with improvements. A 5% improvement in retention can double revenue.

// Firebase Funnel definition (in Firebase Console)
// Step 1: app_open -> Step 2: sign_up_started -> Step 3: sign_up_completed

A/B Testing Integration with Analytics

A/B testing optimizes features by showing different variants to user groups and measuring the impact on key metrics. Firebase A/B Testing integrates with Remote Config: define a parameter (like button_color or onboarding_flow), create a test with control and treatment groups, and measure the effect on a goal event (like purchase_completed). Remote Config lets you change app behavior without an app store update. Run tests until statistical significance (p < 0.05). Common tests: onboarding flow variants, pricing page layouts, push notification copy, and feature gating. Always run one test at a time to avoid interaction effects.

// Firebase Remote Config
val remoteConfig = Firebase.remoteConfig
remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
  val buttonColor = remoteConfig.getString("button_color")
  // Apply color to button
}

Privacy Compliance and App Tracking Transparency

Privacy regulations affect analytics implementation globally. GDPR (Europe) requires explicit consent for tracking and the right to delete user data. CCPA (California) requires opt-out options. Apple's App Tracking Transparency (ATT) requires apps to request permission with a prompt before tracking users across other apps. Present a pre-prompt explaining the value of tracking before the system ATT dialog. For GDPR, integrate a consent management platform (CMP) like OneTrust or Usercentrics. Firebase provides consent mode to respect user choices. On Android, Google Play requires a Data Safety section in the store listing declaring what data is collected and why.

// iOS ATT request
import AppTrackingTransparency
ATTrackingManager.requestTrackingAuthorization { status in
  // status: authorized, denied, notDetermined, restricted
}

Dashboards, Reporting, and Data-Driven Decisions

Dashboards transform raw analytics into actionable insights. Firebase Analytics provides a default dashboard with users, sessions, screen views, and engagement metrics. Create custom dashboards in Google Data Studio or Looker connecting to Firebase/BigQuery export. Mixpanel and Amplitude offer visual query builders for ad-hoc analysis. Schedule recurring reports for stakeholders. Key reports: DAU/MAU trend, retention curve, funnel analysis, revenue breakdown, and crash-free user rate. Use data to decide which features to build next. If retention drops after a release, investigate and roll back if needed. Build a culture where product decisions are hypothesis-driven and validated with data.

// BigQuery export query for daily active users
SELECT DATE(event_timestamp) as day, COUNT(DISTINCT user_pseudo_id) as dau
FROM `project.analytics_123.events_*`
GROUP BY day ORDER BY day DESC

Frequently Asked Questions

What is the difference between events and user properties?

Events track individual user actions at a point in time. User properties track attributes of the user that persist across sessions, like subscription status or device model. Use events for counting actions, user properties for segmenting users.

How many events should I track?

Start with 10-20 core events covering the critical user journey. Add events as needed but avoid tracking everything, which creates noise and performance overhead. Firebase Analytics limits to 500 unique event types.

Do I need user consent before tracking?

Yes for GDPR (Europe) and similar regulations. Use ATT on iOS and a CMP for web/Android. Always provide opt-out mechanisms. Honor Do Not Track settings. Consult legal counsel for your specific jurisdiction.

How do I track uninstalls?

You cannot directly detect uninstalls on iOS or Android. Instead, track user inactivity. If a user has not opened the app for 30+ days and does not respond to push notifications, they are effectively uninstalled. Firebase Analytics tracks churn prediction.

Originally published on Ayodhyyya. Last updated June 1, 2026.