Google Firebase Analytics

You'll need to import the javascript file in your website before starting from this .

1) To enable/disable Analytics data collection

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.setCollection({
    enabled: true/false
})

2) To identify user

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.setUserId({
    userId: "customuserId"
})

3) To set user properties like name, gender etc

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.setUserProperty({
    key: 'name',
    value:'Webtonative'
})

4) To set default parameter which will be passed along with all future events

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.setDefaultEventParameters({
    parameters: {
        "level_name": "Caverns01",
        "level_difficulty": 4
    }
})

5) To Log events

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.logEvent({
    eventName:'Your event name',
    parameters:{
        "level_name": "Caverns01",
        "level_difficulty": 4
    }
})

6) To Track screen view in your website

const { Analytics: FirebaseAnalytics } = window.WTN.Firebase

FirebaseAnalytics.logScreen({
    screenName:"Screen Name",
    screenClass:"Screen Class"
})

Last updated