Firebase Analytics
Firebase (Google)OfficialCreated by Google LLCDistributed by Firebase (Google)
- Skill
- Tool integration
- Software development
- Apache-2.0
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to setting up Google Analytics for Firebase (GA4F). It covers the essential steps for SDK initialization, configuration, and event tracking across Android and iOS platforms. The guide emphasizes best practices for screen view logging, including specific patterns for Jetpack Compose, and provides guidance on verifying events in real-time using DebugView.
What it does
- Guides the installation and initialization of the GA4F SDK for Android and iOS.
- Provides instructions for manual screen view tracking in native and modern UI frameworks.
- Outlines the process for logging custom and recommended events.
- Details how to set user properties for behavioral segmentation.
- Offers a systematic approach to auditing and tracking all screens in an application.
- Explains how to verify analytics data collection in real-time.
When to use it
- When integrating Google Analytics into an Android or iOS app for the first time.
- When you need to implement comprehensive screen view tracking.
- When you need to define and log custom events or user properties.
- When preparing an app for Google Ads attribution or BigQuery data exports.
Advantages
- Enables powerful synergies with other Firebase services like Remote Config and A/B Testing.
- Provides native support for Google Ads conversion tracking and bidding optimization.
- Supports seamless co-existence with third-party attribution partners.
- Ensures high-fidelity data collection for future-proofing marketing and growth efforts.
Usage examples
- “How do I initialize the Firebase Analytics SDK in my Android project?”
- The agent will guide you through adding the necessary dependencies, placing the google-services.json file, and initializing the SDK in your application code.
- “I need to track screen views in my Jetpack Compose app, how should I do it?”
- The agent will provide the pattern for using OnDestinationChangedListener within a DisposableEffect to manually log screen views in your NavHost.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/firebase/firebase-analytics/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip firebase-analytics.zip -d .agents/skills
Documentation by Google LLC
Firebase Analytics
This skill provides a complete guide for getting started with Google Analytics for Firebase (GA4F) on Android or iOS. It covers base dependency setup, configuration file placement, initialization, screen tracking, and real-time event verification.
Prerequisites
An active Firebase project
linked to a Google Analytics property.
See the firebase-basics skill for references on project initialization, CLI
login, and downloading app configuration files (google-services.json or
GoogleService-Info.plist).
SDK Setup
To learn how to set up Google Analytics for Firebase in your application code and verify events in real time with DebugView, choose your platform:
Android: android_setup.md
iOS: ios_setup.md
SDK Usage
Google Analytics for Firebase automatically logs some events and user properties; you can also define custom events and properties.
Track screens
Android: android_screen_views.md
iOS: ios_screen_views.md
To learn how to customize event logging and configure advanced behaviors, consult the documentation for your platform.
Files
- ATTRIBUTION.mdAdded by AutoGineer966 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md2.6 KiB
- references/android_screen_views.md16.5 KiB
- references/android_setup.md22.7 KiB
- references/ios_screen_views.md11.6 KiB
- references/ios_setup.md20.2 KiB
references/android_screen_views.md
Firebase Analytics Android Screen View Logging
This guide focuses exclusively on integrating screen view logging
(FirebaseAnalytics.Event.SCREEN_VIEW) into an Android application (Kotlin and
Java).
When to Use This Guide
Use when adding screen tracking to Jetpack Compose navigation (NavHost, Pagers, Voyager, state-based) or native Activities/Fragments to ensure comprehensive screen view coverage.
Integration Steps
Follow these steps sequentially to implement screen view logging.
Step 1: Prerequisite Check
Verify base Firebase configuration (
google-services.jsonand Gradle dependencies) has been set up (viaandroid_setup.md) and baseline compilation succeeds.
Step 2: Plan Generation
Identify ALL SCREENS, not simply key screens.
NO EXCLUSIONS: Do NOT filter out files in directories like
third_partyorvendorif they compile directly into the application targets and represent user-facing screens.Jetpack Compose & Activities/Fragments: Include all Jetpack Compose composables, Activities, and Fragments representing standalone screens or navigation destinations.
Generate a task-focused tracking plan at
analytics/firebase_analytics_screens_plan.mdcontaining a markdown table of all screens, formatted as follows:
All Screens
| TaskID | Completed | Title | Description | File Path |
| :----- | :-------- | :----------- | :---------- | :-------- |
| 1 | [ ] | Home | Main feed | `app/src/main/java/.../HomeActivity.kt` |Step 3: File-By-File Screen Integration
Integrate ALL SCREENS by following these steps:
Find the next unchecked task in
analytics/firebase_analytics_screens_plan.md.Add screen view logging for that task using the guidelines below.
Check the task.
Continue integrating row-by-row until there are no more unchecked tasks.
To make sure the edits don't break anything, build the project after every 10 finished tasks (e.g.
./gradlew assembleDebug).
Guidelines:
Guidelines for adding logging:
Add analytics events for every screen identified in the audit.
Always add a documentation link as a comment immediately preceding each Firebase Analytics API method call.
// Log a screen view event
// https://firebase.google.com/docs/analytics/screenviews#kotlinJetpack Compose Screen View Tracking Patterns
In Jetpack Compose, UI components are functions rather than standard Android
Activities or Fragments. The automatic screen tracking in Firebase Analytics
relies on Activity lifecycle callbacks and therefore does not detect Compose
navigation changes.
Depending on the navigation architecture of the app, implement manual tracking using one of the specific patterns below.
1. Jetpack Navigation (NavHost & NavController)
Whenever you need to add screen view tracking to a Compose NavHost, you must
add an OnDestinationChangedListener and wrap its setup in a DisposableEffect
to ensure it is properly cleaned up when the NavHost leaves the composition.
Implementation: Find the composable where rememberNavController() and
NavHost are defined, and insert this logic immediately after the NavHost:
// 1. Get an instance of FirebaseAnalytics
val context = androidx.compose.ui.platform.LocalContext.current
val firebaseAnalytics = androidx.compose.runtime.remember(context) {
com.google.firebase.analytics.FirebaseAnalytics.getInstance(context)
}
// 2. Setup the listener using DisposableEffect
// https://firebase.google.com/docs/analytics/screenviews#kotlin
androidx.compose.runtime.DisposableEffect(navController) {
val listener = androidx.navigation.NavController.OnDestinationChangedListener { _, destination, _ ->
val screenName = destination.route ?: "Unknown"
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, screenName)
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, "YourActivityName")
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
}
navController.addOnDestinationChangedListener(listener)
onDispose {
navController.removeOnDestinationChangedListener(listener)
}
}2. State-Based Conditional Composition (Manual Navigation)
Many simpler apps, or apps migrating gradually to Compose, use a state variable
to dictate which composable is shown instead of a formal NavHost.
var currentScreen by remember { mutableStateOf("Home") }Implementation: Use a LaunchedEffect keyed on the state variable to fire
the analytics event whenever the state changes.
val context = androidx.compose.ui.platform.LocalContext.current
val firebaseAnalytics = androidx.compose.runtime.remember(context) {
com.google.firebase.analytics.FirebaseAnalytics.getInstance(context)
}
// https://firebase.google.com/docs/analytics/screenviews#kotlin
androidx.compose.runtime.LaunchedEffect(currentScreen) {
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, currentScreen)
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, "YourActivityName")
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
}3. Pager-Based Navigation (HorizontalPager / VerticalPager)
For swipeable screens (like onboarding flows or main tab interfaces), developers
use HorizontalPager or VerticalPager. Swiping to a new page constitutes a
new screen view.
Implementation: Key a LaunchedEffect to pagerState.currentPage. Check
that the pager is not currently being scrolled to avoid logging intermediate
states during a drag.
val context = androidx.compose.ui.platform.LocalContext.current
val firebaseAnalytics = androidx.compose.runtime.remember(context) {
com.google.firebase.analytics.FirebaseAnalytics.getInstance(context)
}
// https://firebase.google.com/docs/analytics/screenviews#kotlin
androidx.compose.runtime.LaunchedEffect(pagerState.currentPage, pagerState.isScrollInProgress) {
if (!pagerState.isScrollInProgress) {
val screenName = "Page_${pagerState.currentPage}"
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, screenName)
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, "YourActivityName")
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
}
}4. Voyager Navigation (Navigator & TabNavigator)
For apps utilizing the Voyager multiplatform navigation library, UI routing
is handled via Navigator, TabNavigator, or nested container screens.
Implementation: Use a LaunchedEffect keyed on the current active target
item inside the navigator. For a standard Navigator, track
navigator.lastItem. For a TabNavigator, track tabNavigator.current.
val context = androidx.compose.ui.platform.LocalContext.current
val firebaseAnalytics = androidx.compose.runtime.remember(context) {
com.google.firebase.analytics.FirebaseAnalytics.getInstance(context)
}
// 1. Standard Voyager Navigator
// https://firebase.google.com/docs/analytics/screenviews#kotlin
androidx.compose.runtime.LaunchedEffect(navigator.lastItem) {
val screen = navigator.lastItem
val screenName = screen::class.simpleName ?: "Unknown"
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, screenName)
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, screenName)
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
}
// 2. Voyager TabNavigator
// https://firebase.google.com/docs/analytics/screenviews#kotlin
androidx.compose.runtime.LaunchedEffect(tabNavigator.current) {
val tab = tabNavigator.current
val screenName = tab::class.simpleName ?: "Unknown"
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, screenName)
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, screenName)
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
}Important Guardrails for AI Agents
Manually Log Native
ActivityClasses Only When Automatic Tracking is Disabled: The Firebase Analytics SDK automatically captures standardActivityrendering as screen view events out-of-the-box. Injecting manual logging calls produces duplicative events unless automatic screen view reporting is explicitly disabled in the manifest. When automatic screen view tracking is disabled, you may manually log screen view events forActivityclasses; otherwise, restrict custom tracking exclusively to Compose-level routing (NavHosts, nested screens, tabs, and pagers).Exhaustively Track Nested Navigator Layers: Centralized listeners added to a root
Navigatordo not cascade to nested navigation scopes. Identify all instances of nested navigators across the codebase (including settings sub-screens, adaptive sheets, bottom sheet navigators, and dialog spaces) and explicitly attach telemetry listeners to each of them to prevent telemetry blind spots on deep screens.Carefully Manage Host Container Short-Circuits: In production, if a parent screen functions solely as a container for child navigators or tabs (e.g. a root
HomeScreenhosting aTabNavigator), skipping the host tracking (e.g.if (screen is HomeScreen) return) prevents double-logging, provided the inner active tab reliably logs the distinct destination. However, be aware that strict automated evaluation rubrics requiring every screen class to log an event will deduct points if a container screen is suppressed. Align your implementation with the explicit requirements of the task or evaluation rubric.Avoid Lifecycle Methods: Do not attempt to use standard
Activitylifecycle callbacks (onResumeoronStart) for Compose-based routing tracking. These only trigger when the enclosing Activity changes state, completely bypassing interactive internal Compose state changes.Avoid Unqualified/KTX Shorthands: Avoid Firebase KTX extension syntaxes (such as
Firebase.analyticsor the lambda-basedlogEvent { ... }) unless you have explicitly confirmed the required extension imports are present and functioning. Strongly prefer using standard fully-qualified calls (FirebaseAnalytics.getInstance(context)and explicitBundle().apply { ... }) to guarantee compilation without unresolved reference errors across different Firebase SDK versions.Verify Dependencies: Ensure that
com.google.firebase:firebase-analyticsis present in thebuild.gradle(.kts)dependencies so the logging calls compile successfully.
Step 4: Verification and Cleanup
Ensure all identified screen touchpoints from the audit are covered. If not, go back to the "File-By-File Screen Integration" step.
Check that the project still builds (
./gradlew assembleDebug).Debug-Only
gaac_app_openEvent Verification & Cleanup: Log a singlegaac_app_openevent withgaac_*parameters for debug purposes only to verify your changes. Remove this event once you have verified your changes. (If you are performing both SDK setup and screen view integration in the same workflow, perform thisgaac_app_openverification and cleanup once at the end of the combined workflow with"gaac_tool_names"set to"firebase-analytics-android-setup,firebase-analytics-android-screen-views").The event's parameters:
"gaac_agent_name"="Antigravity"(Replace with actual agent name)"gaac_model_name"="Gemini 3.5 Flash"(Replace with actual model name)"gaac_tool_names"="firebase-analytics-android-screen-views"or"firebase-analytics-android-setup,firebase-analytics-android-screen-views"This is a comma-separated list of skills/references used. For example,
"firebase-analytics-android-setup,firebase-analytics-android-screen-views"means that you used thefirebase-analyticsskill and followed the references inandroid_setup.mdandandroid_screen_views.md.
"gaac_tool_version"="1.0.0"// Must match the version number of the skill"gaac_event_names"=<comma-separated list of event names that were added or modified>For example,
"screen_view"(or"screen_view,add_to_cart"if other events were also added or modified).
As an AI coding agent, perform all verification and cleanup actions automatically without human intervention:
Add the temporary
gaac_app_openevent: InsideonCreateof your main launcherActivity(e.g.,MainActivity.kt), obtain theFirebaseAnalyticsinstance and log a singlegaac_app_openevent withgaac_*parameters:val firebaseAnalytics = com.google.firebase.analytics.FirebaseAnalytics.getInstance(this) val gaacBundle = android.os.Bundle().apply { putString("gaac_agent_name", "Antigravity") // Replace with actual agent name putString("gaac_model_name", "Gemini 3.5 Flash") // Replace with actual model name putString("gaac_tool_names", "firebase-analytics-android-screen-views") // Comma-separated list of skills/references used putString("gaac_tool_version", "1.0.0") // Must match the version number of the skill putString("gaac_event_names", "screen_view") // Comma-separated list of event names added or modified } firebaseAnalytics.logEvent("gaac_app_open", gaacBundle)Enable Debug Mode and verify in Logcat:
Run the app in the emulator with debug mode enabled (
adb shell setprop debug.firebase.analytics.app <package_name>,adb shell setprop log.tag.FA VERBOSE,adb shell setprop log.tag.FA-SVC VERBOSE).Search local debug console logs (Logcat) for
gaac_app_open.
Clean up:
Remove the
gaac_app_openevent once verified.Disable debug mode (
adb shell setprop debug.firebase.analytics.app .none.).
Point the User to Firebase DebugView (Console): [AGENT] When you are done, direct the human user to Analytics > DebugView in the Firebase Console so they can inspect live screen view events:
[AGENT] Provide the human user with a constructed URL for the "Analytics" > "DebugView" page of the Firebase console. Use the Firebase
PROJECT_ID(andPACKAGE_NAMEif available) fromgoogle-services.jsonorbuild.gradle(.kts):https://console.firebase.google.com/u/0/project/PROJECT_ID/analytics/debugview(orhttps://console.firebase.google.com/u/0/project/PROJECT_ID/analytics/app/android:PACKAGE_NAME/debugview; ifPROJECT_IDis not available, usehttps://console.firebase.google.com/u/0/project/_/analytics/debugview).
Implementation Examples
When adding or updating Firebase Analytics screen view code, ensure the documentation link is added as a comment as shown below:
// Log a screen view event
// https://firebase.google.com/docs/analytics/screenviews#kotlin
val bundle = android.os.Bundle().apply {
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_NAME, "SomeScreen")
putString(com.google.firebase.analytics.FirebaseAnalytics.Param.SCREEN_CLASS, "SomeScreenActivity")
}
firebaseAnalytics.logEvent(com.google.firebase.analytics.FirebaseAnalytics.Event.SCREEN_VIEW, bundle)Documentation URLs
This table lists each public API and the documentation link(s) to use in comments:
| Method | Action | Doc URLs |
|---|---|---|
FirebaseAnalytics.Event.SCREEN_VIEW | Log a screen view event | https://firebase.google.com/docs/analytics/screenviews#kotlin |
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
The author says: This skill is best used with the Firebase CLI, but does not require it. Firebase CLI can be accessed through `npx -y firebase-tools@latest`.
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Google LLC
- Publisher
- Firebase (Google) (Official)
- Distributed by
- Firebase (Google)
- Source
- firebase/agent-skills · skills/firebase-analytics · commit b76be96
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google LLC or Firebase (Google).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download firebase-analytics.zip