Google Firebase Analytics

Integrating Google Firebase Analytics

This guide will help you integrate Google Firebase Analytics into your app. Firebase Analytics is a powerful tool that provides unlimited analytics at no cost, helping you understand user behavior to make informed decisions about app marketing and performance optimizations.

Adding Firebase Analytics

  1. Integrate Firebase Analytics: Add Firebase Analytics to your cart . Refer to the Firebase documentation for instructions specific to your platform.

Untitled design - 2024-05-29T152217.585.png

  1. Configure Firebase Analytics:
    • Go to plugins integration in your app settings.

    • Navigate to Firebase Analytics settings.

Untitled design - 2024-05-29T152609.118.png

  • Upload your google-service.json file.

Untitled design - 2024-05-29T153107.420.png

Firebase Analytics Functions

1. Enable/Disable Analytics Data Collection

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.setCollection({
   enabled: true // or false
});

ES6+:

import { setCollection } from "webtonative/Firebase/Analytics";
 
setCollection({
    enabled: true // or false
});

2. Identify User

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.setUserId({
   userId: "customuserId"
});

ES6+:

import { setUserId } from "webtonative/Firebase/Analytics";
 
setUserId({
    userId: "customuserId"
});

3. Set User Properties

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.setUserProperty({
   key: 'name',
   value: 'Webtonative'
});

ES6+:

import { setUserProperty } from "webtonative/Firebase/Analytics";
 
setUserProperty({
    key: 'name',
    value: 'Webtonative'
});

4. Set Default Event Parameters

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.setDefaultEventParameters({
   parameters: {
       "level_name": "Caverns01",
       "level_difficulty": 4
   }
});

ES6+:

import { setDefaultEventParameters } from "webtonative/Firebase/Analytics";
 
setDefaultEventParameters({
    parameters: {
        "level_name": "Caverns01",
        "level_difficulty": 4
    }
});

5. Log Events

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.logEvent({
   eventName: 'Your event name',
   parameters: {
       "level_name": "Caverns01",
       "level_difficulty": 4
   }
});

ES6+:

import { logEvent } from "webtonative/Firebase/Analytics";
 
logEvent({
    eventName: 'Your event name',
    parameters: {
        "level_name": "Caverns01",
        "level_difficulty": 4
    }
});

6. Track Screen View

Plain JavaScript:

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase;
 
FirebaseAnalytics.logScreen({
   screenName: "Screen Name",
   screenClass: "Screen Class"
});

ES6+:

import { logScreen } from "webtonative/Firebase/Analytics";
 
logScreen({
    screenName: "Screen Name",
    screenClass: "Screen Class"
});

Save and Rebuild

After making these changes, save your settings and rebuild your app to see the changes in action. This ensures that all configurations are applied correctly and Firebase Analytics functions as expected.


media-icon
media-icon
media-icon
media-icon

â“’2024 Orufy Technologies All Rights Reserved.