Skip to content

Brightscript implementation of Google Analytics 4 (GA4), That is compatible with Firebase

License

Notifications You must be signed in to change notification settings

vixtech/roku-google-analytics-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

roku-google-analytics-4

Brightscript implementation of Google Analytics 4 (GA4) That is compatible with Firebase

Installation

Copy the files inside "components" to your application.

Usage

Put the code bellow in the start of your MainScene.

m.global.AddField("analytics", "node", false)
m.global.analytics = CreateObject("roSGNode", "GoogleAnalytics")
m.global.analytics.callFunc("initialize", {
  measurementId: "G-YOURMEASURENTID"
  appName: "YOUR APP NAME"
  docLocation: "https://YOUR DOC LOCATION"
  customArgs: {
    "ep.EXAMPLEPROPERTY": "HERE YOU CAN PUT ANY CUSTOM ARG, FOR EXAMPLE A DEFAULT EVENT PROPERTY (ep.*)"
  }
  isFirstOpen: myIsFirstOpen ' THIS VALUE IS OPTIONAL, THE DEFAULT BEHAVIOR IS TO USE THE STORAGE TO KNOW IF IT's THE FIRST OPEN
  userId: myUserId
  userProperties: {
    "userPropA": "SET USER PROPERTIES HERE"
  }
})
m.global.analytics.callFunc("start")

You can change the userId and userProperty later

m.global.analytics.callFunc("setUserId", myUserId)
m.global.analytics.callFunc("setUserProperties", myUserProperties)

You can log events with the function:

m.global.analytics.callFunc("logEvent", "my_event_name", {
  "myEventPropertyName": myEventPropertyValue
})

About

Brightscript implementation of Google Analytics 4 (GA4), That is compatible with Firebase

Resources

License

Stars

Watchers

Forks

Packages

No packages published