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
- Create a Firebase project and add an Android and/or iOS app with the identifiers shown in the plugin settings.
- Upload
google-services.jsonandGoogleService-Info.plistin the plugin settings. The same files are used for push notifications and Crashlytics. - 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
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 collectingE-commerce events use GA4 parameters:
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
Consent before the user chooses sets the starting point (changing it needs a new build):
| Setting | Meaning |
|---|---|
followEU | Google's defaults; your consent banner then calls setConsent() |
deny | Nothing is stored until setConsent() |
allow | Everything is allowed by default |
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).