Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
IRoad
Visitor

Google Analytics only in Real Time

Hi guys,
I have a script for track the access on my channel, the problem is when someone watch the channel Google Analytics track the access only in real time but NOT in audience, so few words I don't have an accurate statistic on my channel.
Can help to understand where is the problem? thanks

REM ****************************************
REM ** Tracking Code for Google Analytics **
REM ****************************************

Function analyticsPageView(var_URI As String, var_uservar As String)

?"************************"
?var_URI, var_uservar
?"************************"
timestamp = CreateObject("roDateTime")
xfer = CreateObject("roURLTransfer")

var_utmac = "MO-3951XXXX-1" '** Google Account **
var_utmhn = "roku.XXXXXXXX.XX" '** Domain **
var_utmn = stri(randNumber(1000000000,9999999999)) 'Random Request Number
var_utmn = right(var_utmn,len(var_utmn)-1) 'Remove Space Added By Stri()
var_cookie = stri(randNumber(1000000000,9999999999)) 'Random Cookie Number
var_cookie = right(var_cookie,len(var_cookie)-1) 'Remove Space Added By Stri()
var_random = stri(randNumber(1000000000,2147483647)) 'Random Number Under 2147483647
var_random = right(var_random,len(var_random)-1) 'Remove Space Added By Stri()
var_today = stri(timestamp.asSeconds()) 'Unix Timestamp For Current Date
var_today = right(var_today,len(var_today)-1) 'Remove Space Added By Stri()
var_referer = "Roku" 'Referer Url (Doesn't Exist Here)
if len(var_uservar) = 0 var_uservar = "homescreen" 'User Defined Variable
if len(var_URI) = 0 var_URI = "appHomeScreen.brs" 'URL For Page View

urchin_url = "http://www.google-analytics.com/__utm.gif?utmwv=1&utmn=" + var_utmn
urchin_url = urchin_url + "&utmsr=-&utmsc=-&utmul=-&utmje=0&utmfl=-&utmdt=-&utmhn=" + var_utmhn
urchin_url = urchin_url + "&utmr=" + var_referer
urchin_url = urchin_url + "&utmp=" + xfer.Escape(var_URI)
urchin_url = urchin_url + "&utmac=" + var_utmac
urchin_url = urchin_url + "&utmcc=__utma%3D" + var_cookie
urchin_url = urchin_url + "." + var_random
urchin_url = urchin_url + "." + var_today
urchin_url = urchin_url + "." + var_today
urchin_url = urchin_url + "." + var_today
urchin_url = urchin_url + ".2%3B%2B__utmb%3D" + var_cookie
urchin_url = urchin_url + "%3B%2B__utmc%3D" + var_cookie
urchin_url = urchin_url + "%3B%2B__utmz%3D" + var_cookie
urchin_url = urchin_url + + var_today
urchin_url = urchin_url + ".2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B__utmv%3D" + var_cookie
urchin_url = urchin_url + "." + xfer.Escape(var_uservar) + "%3B"

xfer.SetURL(urchin_url)
response = xfer.GetToString()

End Function

Function randNumber(num_min As Integer, num_max As Integer) As Integer
return (RND(0) * (num_max - num_min)) + num_min
End Function
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.