Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
svencoop
Level 8

Firebase Google Analytics

Roku says they will NOT be updating their Analytics lib to support Firebase!

Does anybody have any ideas how to log Firebase events from RSG???

Any wiz kids out there that can convert the JavaScript to BrightScript?

https://firebase.google.com/docs/web/setup

Steve

 

0 Kudos
7 REPLIES 7\
andersonvix
Level 7

Re: Firebase Google Analytics

Hello,

Here we developed a integration with Google Analytics 4 (That is built on top of Firebase Analytics)

You can see here:

https://github.com/vixtech/roku-google-analytics-4

0 Kudos
developer_uj24
Level 7

Re: Firebase Google Analytics

Hi, I wanted to communicate and perform CRUD operations with firebase Realtime database can you provide any help?

0 Kudos
uj24153
Level 9

Re: Firebase Google Analytics

0 Kudos
svencoop
Level 8

Re: Firebase Google Analytics (1 of 2)

Here is my code, not pretty and there is a lot of old unused/commented out stuff, I have not looked at this for a long time...

docLocation is your Google database name - you can see it from BigQuery - it is named  something like analytics_123456789 containing the tables events_ and events_intraday_ 

example: 

BigQuery:   SELECT * FROM `yourdbname.analytics_153576726.events_intraday_20220513` LIMIT 1000
 
use this:  docLocation: "https://yourdbname.firebaseio.com"
 
Steve
 

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- GoogleAnalytics4.xml -->
<!-- ************************************ -->
<!-- Copyright 2021-2021 FutureSoft, Inc. -->
<!-- ************************************ -->

<component name="GoogleAnalytics4" extends="Task">

  <interface>

    <field id="RokuAnalyticsPlayerTitle"    type="string" />
    <field id="RokuAnalyticsPlayerState"    type="string" />
    <field id="RokuAnalyticsEventCategory"  type="string" />
    <field id="RokuAnalyticsEventValue"     type="string" />
    <field id="RokuAnalyticsLoginUserID"    type="string" />

    <!-- Public -->
    <function name="initialize" />
    <function name="setConfig" />
    <function name="setOptions" />
    <function name="start" />
    <function name="logEvent" />
    <function name="logScreenView" />
    <function name="setUserProperties" />
    <function name="setCurrentScreen" />
    <function name="setUserId" />
    <function name="resetAnalyticsData" />

    <field id="httpMethod" type="string" />
    <field id="httpUrl" type="string" />

  </interface>

  <script type="text/brightscript" uri="GoogleAnalytics4.brs" />

</component>

<!-- ************************************
Usage

Bunch of functions used by many screens:
   <script type="text/brightscript" uri="pkg:/components/compUtils.brs" />

Containing:
Function utilPostAnalytics(passedTitle, passedState, passedCategory, passedUserID, passedEvtCnt)
?"utilPostAnalytics()", passedTitle, passedState, passedCategory, passedUserID
    m.GoogleAnalytics4Obj = createObject("roSGNode", "GoogleAnalytics4")
    m.GoogleAnalytics4Obj.setField("RokuAnalyticsPlayerTitle", passedTitle)
    m.GoogleAnalytics4Obj.setField("RokuAnalyticsPlayerState", passedState)
    m.GoogleAnalytics4Obj.setField("RokuAnalyticsEventValue", passedEvtCnt)
    m.GoogleAnalytics4Obj.setField("RokuAnalyticsEventCategory", passedCategory)
    m.GoogleAnalytics4Obj.setField("RokuAnalyticsLoginUserID", passedUserID)
'STOP
    m.GoogleAnalytics4Obj.control = "RUN"
End Function

Examples: We call every 60 seconds to track in realtime...
sTmpClientID = WhateverCustomerIDYouAssign sTmpEventCnt = 1 utilPostAnalytics(m.videoPlayer.content.Title, "start", "media player", sTmpClientID, sTmpEventCnt) sTmpClientID = WhateverCustomerIDYouAssign sTmpEventCnt = m.sixtySecTimePassed / 60 utilPostAnalytics(m.videoPlayer.content.Title, "playing", "media player", sTmpClientID, sTmpEventCnt) sTmpClientID = WhateverCustomerIDYouAssign sTmpEventCnt = m.sixtySecTimePassed / 60 utilPostAnalytics(m.audioPlayer.content.Title, "finished", "media player", sTmpClientID, sTmpEventCnt) ************************************ --> <!-- ************************************ examples debug output sent to Google... [GoogleAnalytics4] https://analytics.google.com/g/collect ?sid=1611237152&_p=1490261140&_s=1&seg=1&ec=media_player&sr=1280x720&uid=1%3A999999999999%3Aweb%3A7777777777777777777777 &v=2&en=start&sct=279&cid=420d8a2a-d34b-5dd6-9d2f-4305921dacb3&upn.first_open_time=1610744400000 &dl=https%3A%2F%2FBIGQUERY-DBNAME.firebaseio.com&av=4.0.9&custom=unset&ea=start&up.userPropA=USERPROPA &tid=G-ABCDEFGHIJKLMNOP&ul=en_us&cd=media_player&up.id=1%3A999999999999%3Aweb%3A7777777777777777777777 &el=Live%20Stream%20-%20Auf%20Deutsch&an=RokuApp POST https://analytics.google.com/g/collect ?_p=406324644&_s=1&seg=1&sr=1280x720&uid=1%3A999999999999%3Aweb%3A7777777777777777777777&v=2&en=start &cid=420d8a2a-d34b-5dd6-9d2f-4305921dacb3&upn.first_open_time=1610744400000&dl=https%3A%2F%2FBIGQUERY-DBNAME.firebaseio.com &av=4.0.9&up.userPropA=SET%20USER%20PROPERTIES%20HERE&tid=G-ABCDEFGHIJKLMNOABCDEFGHIJKLMNOP&ul=en_us &up.id=1%3A999999999999%3Aweb%3A7777777777777777777777&EXAMPLEPROPERTY=HERE%20YOU%20CAN%20PUT%20ANY%20CUSTOM%20ARG... &an=RokuApp ************************************ -->

 

 

 

 

 

0 Kudos
svencoop
Level 8

Re: Firebase Google Analytics

The docLocation contains your analytics database name...

From BigQuery find the database containing the tables YOUR-DBNAME.analytics_ and YOUR-DBNAME.analytics_intraday_

Example: 

SELECT * FROM `YOUR-DBNAME.analytics_153576726.events_intraday_20220513` LIMIT 1000
Roku code...
   ...
   ...
 
I tried to paste in code, but Roku tagged it as SPAM and deleted my reply!
I will try again today...
 
Steve

 

svencoop
Level 8

Re: Firebase Google Analytics (code example)

Here is my code, very ugly and lots of unused/commented out stuff!

Roku GoogleAnalytics4 XML and BRS

https://pastebin.com/jYM9MU5W#

Steve

 

0 Kudos
developer_uj24
Level 7

Re: Firebase Google Analytics (code example)

Pastebin.com is down and not working.

0 Kudos