Firebase Analytics

Firebase Analytics helps you understand what your users are doing in your app. It has all of the metrics that you’d expect in an app analytics tool (average revenue per user (ARPU), active users, retention reports, event counts, etc.) combined with user properties like device type, app version, and OS version to give you insight into how users interact with your app.

Create a Firebase Project in the Firebase Console

Refer to the Firebase Documentation and follow steps 1 through 3 to set up a project in the Firebase Console. In summary you will provide your Package Name or iOS Bundle ID to then generate a google-services.json file.

Add google-services.json to your app

To add google-services.json to your app download the file (refer to below screenshot) and insert the contents of the file as a JSON object in your appConfig.json as the parameter services.androidGoogleServicesJson

Default logging

By default, Firebase tracks common app events including app start, activities viewed, and app usage.

Advanced logging

Use the GoNative JavaScript Bridge to log additional events through your website

️GoNative JavaScript Bridge

  1. Call firebaseAnalytics.setAnalyticsCollectionEnabled(boolean)
window.location.href = 'gonative://firebaseAnalytics/event/collection?enabled=boolean';
  1. Call firebaseAnalytics.setUserId(String)
window.location.href = 'gonative://firebaseAnalytics/event/setUser?ID=String';
  1. Call firebaseAnalytics.setUserProperty(StringKey, StringValue)
window.location.href = 'gonative://firebaseAnalytics/event/setUserProperty?key=StringKey&value=StringValue';
  1. Call firebaseAnalytics.setDefaultEventParameters(params)
window.location.href = 'gonative://firebaseAnalytics/event/defaultEventParameters?data=jsonString';
//data is an encoded map of key-value pairs converted by the app into bundle params
  1. Call firebaseAnalytics.logEvent(eventName, params)
window.location.href = 'gonative://firebaseAnalytics/event/logEvent?event=StringEvent&data=jsonString';
//called with the fixed screenClass="MainActivity"
  1. Call firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SCREEN_VIEW, bundle)
window.location.href = 'gonative://firebaseAnalytics/event/setUser?ID=String';
  1. Call firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, itemBundle)
window.location.href = 'gonative://firebaseAnalytics/event/viewItem?data=JsonProductItem&currency=StringCurrency&price=DecimalPrice';
// JsonProductItem is an encoded map of ProductItem*
// Currency is the 3-letter currency code in upper-case
// DecimalPrice is the cost per item in the given Currency
  1. Call firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_WISHLIST, bundle)
window.location.href = 'gonative://firebaseAnalytics/event/addToWishlist?data=JsonProductItem&currency=StringCurrency&price=DecimalPrice&quantity=IntegerQuantity';
// JsonProductItem is an encoded map of ProductItem*
// Currency is the 3-letter currency code in upper-case
// DecimalPrice is the cost per item in the given Currency
// IntegerQuantity is the count of the product. It multiplies the DecimalPrice for the total amount.
  1. Call firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_CART, bundle)
window.location.href = 'gonative://firebaseAnalytics/event/addToCart?data=JsonProductItem&currency=StringCurrency&price=DecimalPrice&quantity=IntegerQuantity';
// JsonProductItem is an encoded map of ProductItem*
// Currency is the 3-letter currency code in upper-case
// DecimalPrice is the cost per item in the given Currency
// IntegerQuantity is the count of the product. It multiplies the DecimalPrice for the total amount.
  1. Call firebaseAnalytics.logEvent(FirebaseAnalytics.Event.REMOVE_FROM_CART, bundle)
window.location.href = 'gonative://firebaseAnalytics/event/removeFromCart?data=JsonProductItem&currency=StringCurrency&price=DecimalPrice&quantity=IntegerQuantity';
// JsonProductItem is an encoded map of ProductItem*
// Currency is the 3-letter currency code in upper-case
// DecimalPrice is the cost per item in the given Currency
// IntegerQuantity is the count of the product. It multiplies the DecimalPrice 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