Why use Google Firebase Analytics?
- Real-time insights: User behavior tracking and integration with other Firebase services.
- Essential metrics: ARPU, active users, retention, event counts, device type, app version, OS version.
- Consent management: Configure ad storage, analytics storage, ad user data, and ad personalization at runtime.
- JavaScript Bridge: Enable/disable logging, set user ID and properties, log custom events and screen views, and use e-commerce events.
Prerequisites
- A Median app with the JavaScript Bridge enabled
- A Google Firebase project (Firebase Console)
- Android Package Name (from Median App Studio > Build & Deploy > App Identifiers) for Android
- Apple Bundle ID (from App Studio > Build & Deploy > App Identifiers) for iOS
-
google-services.json(Android) andGoogleService-Info.plist(iOS) from Firebase after app registration - Plugin enabled in App Studio (Native Plugins > Google Firebase Analytics)
Implementation guide
Google Firebase project setup
If you do not have an active Google Firebase project, you may need to create a new project after signing into your Google Firebase Account. Once your project is set up, you can start the integration by choosing either the iOS or Android logo in your Project Overview screen.
Google Firebase project overview
Register your Android app in Firebase
Provide the Android Package Name (found in Median App Studio under Build & Deploy > App Identifiers). See App identifiers.
google-services.json for the App Configuration step. You do not need to add the Firebase SDK manually; the plugin performs that step.

Register your iOS app in Firebase
Provide the Apple Bundle ID (found in App Studio under Build & Deploy > App Identifiers). See App identifiers.
GoogleService-Info.plist for the App Configuration step. You do not need to add the Firebase SDK or initialization code; the plugin performs those steps.

Enable the plugin
- Google Services configuration: Upload GoogleService-Info.plist (iOS) and google-services.json (Android) in Build & Deploy > Google Services in App Studio. You can upload files from Firebase or copy and paste their contents.
- Consent configuration: In Plugin Settings, set your default consent value: Follow EU Consent Policy (deny for users in regions subject to the EU User Consent Policy), Deny (deny consent), or Allow (grant consent).
- Plugin activation: Enable the plugin in App Studio via Native Plugins > Google Firebase Analytics > Settings.
Finalizing the app build
Once you upload the configuration files, save the changes and rebuild your app.
Use your AI agent
Use the Median MCP with your AI agent to enable Firebase Analytics and add your Firebase configuration files to your mobile app. See Median MCP server to set it up.
JavaScript Bridge functions
Consent management
Configure consent for ad storage, analytics storage, ad user data, and ad personalization at runtime.Analytics management
Enable or disable all event logging (including automatic app events). Logging is enabled by default. Effect is persistent; once disabled, re-enable by calling again withtrue.
User management
Set a custom user ID (for example, after sign-in when the user is no longer anonymous).Set user property
Associate additional properties with the user.Event logging
Set default event parameters logged alongside other information for log event.Log event
Log a custom event. Thedata object is flexible.
Log screen
Log a customized screen view event (in addition to default logging).E-commerce events
Firebase offers a special command set that is tailored for e-commerce integrations. You can learn more about the commands in the Firebase Measure e-commerce documentation. Log item viewsProductItem may include the following fields. All fields are optional though it is recommended to provide at least an item_id or item_name.
Default event logging
By default, Firebase Analytics automatically logs key events such asscreen_view, session_start, and first_open_time. For a complete list of automatic events, see Google Analytics documentation.
Testing checklist
Basic functionality- Plugin is enabled in App Studio (
Native Plugins > Google Firebase Analytics > Settings) -
google-services.json(Android) andGoogleService-Info.plist(iOS) are uploaded inBuild & Deploy > Google Services - App rebuilt after configuration changes
- Firebase Analytics initializes without JavaScript Bridge errors
-
median.firebaseAnalytics.event.setConsent(...)behaves as expected for your test scenario -
median.firebaseAnalytics.event.collection({'enabled': false})thentruechanges logging behavior
- Default consent option in Plugin Settings matches your policy (
Follow EU Consent Policy,Deny, orAllow) -
setUser,setUserProperty,logEvent,logScreen, and e-commerce calls appear in Firebase Analytics as expected
- Consent and analytics behavior align with your privacy disclosures
- Custom events and screen views do not block core web flows
Troubleshooting
Firebase Analytics functions are undefined or not working
Enable the JavaScript Bridge in App Studio, then call Firebase methods after themedian_library_ready() event. In App Studio (Native Plugins > Google Firebase Analytics), confirm the plugin is enabled and that GoogleService-Info.plist (iOS) and google-services.json (Android) are uploaded under Build & Deploy > Google Services. Save and rebuild after configuration changes.
Custom events are not appearing in Firebase Analytics
Verify event collection is enabled withmedian.firebaseAnalytics.event.collection({'enabled': true}). Then trigger a known test event, for example median.firebaseAnalytics.event.logEvent({'event': 'test_event', 'data': {...}}), and confirm your app build includes the latest plugin and Google Services configuration files.
Consent behavior does not match the selected policy
Check the default consent option in Plugin Settings (Follow EU Consent Policy, Deny, or Allow) and confirm you are not overriding it unexpectedly at runtime. If you call setConsent, verify each key (adStorage, analyticsStorage, adUserData, adPersonalization) is set to the intended boolean value.
User ID or user properties are missing from analytics data
Set the user ID only after the user is authenticated usingmedian.firebaseAnalytics.event.setUser({'ID': 'your_user_id'}), then apply properties with setUserProperty. Trigger a follow-up event after those calls so the updated identity and properties are attached to event data.
E-commerce events are incomplete or rejected
Confirm your e-commerce payload includes validcurrency (3-letter uppercase code), numeric price, and quantity where required. For data, include a valid ProductItem map and provide at least item_id or item_name to improve event quality and reporting reliability.
Still having trouble?For Firebase Analytics behavior outside Median’s bridge, refer to the Google Firebase Analytics documentation.