Skip to main content
Native Plugins & Integrations1 min read

Firebase Analytics

Add Google Analytics for Firebase to your app: automatic screen views, custom and e-commerce events from your website, consent and privacy settings.

Overview

The Firebase Analytics plugin sends screen views and events from your app to Google Analytics for Firebase. WebAppStudio has no analytics dashboard of its own; you view the data in your Firebase project (and store statistics in Play Console and App Store Connect).

Setup

  1. Create a Firebase project and add an Android and/or iOS app with the identifiers shown in the plugin settings.
  2. Upload google-services.json and GoogleService-Info.plist in the plugin settings. The same files are used for push notifications and Crashlytics.
  3. Turn the plugin on in Integrations › Native plugins and build a new version.

Automatic screen views

Every page the app shows is logged as a screen_view, with the path only (no query string, so no emails or tokens). Turn Log a screen view for every page off if your site already sends page views with Google Analytics, to avoid counting them twice.

Events from your page

javascript
wapp.firebaseAnalytics.logEvent({ event: 'sign_up', data: { method: 'email' } });
wapp.firebaseAnalytics.setUser({ id: 'customer-42' });     // null clears it
wapp.firebaseAnalytics.setUserProperty({ key: 'plan', value: 'gold' });
wapp.firebaseAnalytics.logScreen({ screen: '/checkout/step-2' });
wapp.firebaseAnalytics.defaultEventParameters({ app_section: 'shop' });
wapp.firebaseAnalytics.collection({ enabled: false });      // stop collecting

E-commerce events use GA4 parameters:

javascript
wapp.firebaseAnalytics.viewItem({ currency: 'USD', value: 24.5,
  items: [{ item_id: 'SKU_1', item_name: 'T-shirt', price: 24.5 }] });
wapp.firebaseAnalytics.purchase({ transaction_id: 'T_1001', currency: 'USD', value: 49, items: [] });

Also available: addToWishlist, addToCart, removeFromCart and beginCheckout.

Consent before the user chooses sets the starting point (changing it needs a new build):

SettingMeaning
followEUGoogle's defaults; your consent banner then calls setConsent()
denyNothing is stored until setConsent()
allowEverything is allowed by default
javascript
wapp.firebaseAnalytics.setConsent({ analyticsStorage: 'granted', adStorage: 'denied',
  adUserData: 'denied', adPersonalization: 'denied' });

The advertising ID is not collected unless you turn on Collect the advertising ID. On iPhone that also needs the App Tracking Transparency prompt.

Declare analytics in App Store Connect (App Privacy) and in Play Console (Data safety).

Next steps