I am having trouble with logging events using the Measurement Protocol for Universal Google Analytics. Below is the function in question. I know spaces have to be urlencoded but I cant seem to get xfer.Escape or xfer.urlencode to work on the payload. Any help in the right direction is appreciated. Thanks.
Function UA_trackEvent(EventCat as String , EventAct as String , EventLab as String , EventVal as String) as Void
payload = "v=1"
payload = payload + "&uid=" + m.UATracker.userID
payload = payload + "&cid=" + m.UATracker.clientID
payload = payload + "&tid=" + m.UATracker.AccountID
payload = payload + "&dimension1=" + m.UATracker.model
'payload = payload + "&dimension2=" + m.UATracker.DisplayName
payload = payload + "&sr=" + m.UATracker.display
payload = payload + "&sd=" + m.UATracker.ratio
payload = payload + "&dr=" + config().trafSource
'payload = payload + "&an=" + m.UATracker.appName
'payload = payload + "&av=" + m.UATracker.appVersion
payload = payload + "&t=" + "event"
If Len(EventCat) > 0
payload = payload + "&ec=" + EventCat <-- problem area
end if
If Len(EventAct) > 0
payload = payload + "&ea=" + EventAct
end if
If Len(EventLab) > 0
payload = payload + "&el=" + EventLab <-- problem area
end if
If Len(EventVal) > 0
payload = payload + "&ev=" + EventVal
end if
xfer = CreateObject("roURLTransfer")
xfer.Addheader("x-roku-reserved-dev-id","")
xfer.SetURL(m.UATracker.endpoint + "?" + payload + "&z=" + GetRandomInt(10))
response = xfer.GetToString()
End Function
in the video brs file I am calling
UA_trackEvent("Video Plays", "play", episode.title, "")
the episode.title has spaces in it.