So, you need an iframe to put the file with the GA fragment inside. The file must be located on the remote server, because Samsung Smart TV applications run on the local host, and GA ignores calls from the local host.
<iframe name='ga' src="http://example.com/ga.html" width="0" height="0"/>
From a GA snippet, you can delete a line if you do not want GA to count trackPage when loading an iframe.
_gaq.push(['_trackPageview']);
Then in the main script you add this function:
var trackPage = function(url) { if (window.ga && window.ga._gaq) window.ga._gaq.push(['_trackPageview', '/samsung' + url.replace(/ /g, "_")]); };
Thus, to call trackPage("/sports/football/barcelona chelsea")
somewhere in the application, a GA track with the exact URL will be created:
/samsung/sports/football/barcelona_chelsea
It is very effective - you can play with GA Real time, and you can see how well it works. Because GA works asynchronously, the iframe never reloads.
source share