Google Firebase Analytics

Unlock real-time insights, user behavior tracking, and integration with other Firebase services.

Google Firebase Analytics provides powerful insights into user behavior within your app, helping you understand how users engage and interact. It offers essential app metrics such as average revenue per user (ARPU), active users, retention reports, and event counts, along with detailed user properties like device type, app version, and OS version. By combining these data points, Firebase Analytics enables data-driven decision-making to optimize app performance and user experience.

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 eCommerce events.

Prerequisites

  • A Median.co app with JavaScript Bridge enabled
  • A Google Firebase project (Firebase Console)
  • Android Package Name (from Median App Studio > Build & Download > App Identifiers) for Android
  • Apple Bundle ID (from App Studio > Build & Download > App Identifiers) for iOS
  • google-services.json (Android) and GoogleService-Info.plist (iOS) from Firebase after app registration
  • Plugin enabled in App Studio (Native Plugins > Google Firebase Analytics)
👍

Developer Demo

Display our demo page in your app to test during development https://median.dev/firebase-analytics/


When to use this plugin

Firebase Analytics is essential for apps that need to:

Use CaseExample
User behaviorUnderstand how users engage and interact with the app
MetricsARPU, active users, retention, event counts
ConsentComply with EU User Consent Policy (deny/allow for ad and analytics storage)
Custom eventsLog custom events and screen views via the JavaScript Bridge
eCommerceLog add to cart, remove from cart, wishlist, view item (Firebase eCommerce events)

What you'll do

  1. Firebase project: Create or open a project and register Android and iOS apps (Google Firebase Project Setup).
  2. Upload configs: Add GoogleService-Info.plist and google-services.json in App Studio (Build & Download > Google Services), set consent defaults, enable the plugin, and rebuild (Plugin setup).
  3. Runtime APIs: Use median.firebaseAnalytics.event.* for consent, collection, user, events, screens, and eCommerce (JavaScript bridge functions).
  4. Verify: Use Testing Checklist and the Firebase / Google Analytics consoles.

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 setup you can start the integration by choosing either the iOS or Android logo in your Project Overview screen.

Google Firebase - Project Overview

Google Firebase - Project Overview

Register your app in Firebase

Provide the Android Package Name (found in Median App Studio under Build & Download > App Identifiers). See App Identifiers.

Register your Android app

Once registered, download google-services.json for the App Configuration step. You do not need to add the Firebase SDK manually; the plugin performs that step.


Download the google-services.json configuration file

Enable the Plugin

  1. Google Services Configuration: Upload GoogleService-Info.plist (iOS) and google-services.json (Android) in Build & Download > Google Services in App Studio. You can upload files from Firebase or copy and paste their contents.
  2. 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).
  3. 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.

Upload your GoogleService-Info.plist and google-services.json configurations

JavaScript Bridge Functions

Consent Management

Configure consent for ad storage, analytics storage, ad user data, and ad personalization at runtime.

↔️Median JavaScript Bridge

median.firebaseAnalytics.event.setConsent({
  "adStorage": true|false,
  "analyticsStorage": true|false,
  "adUserData": true|false,
  "adPersonalization": true|false
});

Parameters:

ParameterTypeRequiredDescription
Consent objectobjectYesBoolean keys: adStorage, analyticsStorage, adUserData, adPersonalization

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 with true.

↔️Median JavaScript Bridge

median.firebaseAnalytics.event.collection({'enabled':BOOLEAN});

Parameters:

ParameterTypeRequiredDescription
enabledbooleanYesWrapped in { enabled: ... }

User Management

Set a custom user ID (e.g. after login when the user is no longer anonymous).

↔️Median JavaScript Bridge

median.firebaseAnalytics.event.setUser({'ID':STRING});

Parameters:

ParameterTypeRequiredDescription
IDstringYesPassed as 'ID' on the object

Set User Property

Associate additional properties with the user.

median.firebaseAnalytics.event.setUserProperty({'key': STRING, 'value': STRING});

Parameters:

ParameterTypeRequiredDescription
key / valuestringYesProperty name and value

Event Logging

Set default event parameters logged alongside other information for log event.

↔️Median JavaScript Bridge

median.firebaseAnalytics.event.defaultEventParameters(data);
//data is an object of key-value pairs converted into bundle params

Parameters:

ParameterTypeRequiredDescription
dataobjectYesKey-value pairs

Log Event

Log a custom event. The data object is flexible.

median.firebaseAnalytics.event.logEvent({ 'event': STRING, 'data': OBJECT });

Parameters:

ParameterTypeRequiredDescription
eventstringYesEvent name
dataobjectNoArbitrary event payload

Log Screen

Log a customized screen view event (in addition to default logging).

median.firebaseAnalytics.event.logScreen({'screen': STRING});

Parameters:

ParameterTypeRequiredDescription
screenstringYesScreen name

eCommerce Events

Firebase offers a special command set that is tailored for ecommerce integrations. You can learn more about the commands in the Firebase Measure ecommerce documentation.

↔️Median JavaScript Bridge

Log item views

median.firebaseAnalytics.event.viewItem({'data':JsonProductItem, 'currency': STRING, 'price': FLOAT});
// JsonProductItem is an encoded map of ProductItem*
// currency is the 3-letter currency code in upper-case
// price is the cost per item in the given Currency

Log wishlist additions

median.firebaseAnalytics.event.addToWishlist({'data':JsonProductItem, 'currency': STRING, 'price': FLOAT, 'quantity': INTEGER});
// JsonProductItem is an encoded map of ProductItem*
// currency is the 3-letter currency code in upper-case
// price is the cost per item in the given Currency
// quantity is the count of the product. It multiplies the price for the total amount.

Log add to cart events

median.firebaseAnalytics.event.addToCart({'data':JsonProductItem, 'currency': STRING, 'price': FLOAT, 'quantity': INTEGER});
// JsonProductItem is an encoded map of ProductItem*
// currency is the 3-letter currency code in upper-case
// price is the cost per item in the given Currency
// quantity is the count of the product. It multiplies the price for the total amount.

Log remove from cart events

median.firebaseAnalytics.event.removeFromCart({'data':JsonProductItem, 'currency': STRING, 'price': FLOAT, 'quantity': INTEGER});
// JsonProductItem is an encoded map of ProductItem*
// currency is the 3-letter currency code in upper-case
// price is the cost per item in the given Currency
// quantity is the count of the product. It multiplies the price for the total amount.

*Note:
ProductItem may include the following fields. All fields are optional though it is recommended to provide at least an item_id or item_name.

String item_id
String item_name
String item_category
String item_variant
String item_brand
String item_list_name
String item_list_id
double price

Default Event Logging

By default, Firebase Analytics automatically logs key events such as screen_view, session_start, first_open_time. For a complete list of automatic events, see Google Analytics documentation.


Testing Checklist

  • Plugin is enabled in App Studio (Native Plugins > Google Firebase Analytics > Settings)
  • google-services.json (Android) and GoogleService-Info.plist (iOS) are uploaded in Build & Download > 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}) then true changes logging behavior
  • Default consent option in Plugin Settings matches your policy (Follow EU Consent Policy, Deny, or Allow)
  • setUser, setUserProperty, logEvent, logScreen, and eCommerce 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

Enable the JavaScript Bridge in your Median dashboard, then call Firebase methods after the deviceready 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 & Download > Google Services. Save and rebuild after configuration changes.

Verify event collection is enabled with median.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.

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.

Set the user ID only after the user is authenticated using median.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.

Confirm your eCommerce payload includes valid currency (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 Google Firebase Analytics documentation.


Next Steps