1

I am now working on a samsung smart tv app which main purpose is video streaming and I would like to see am I able to track the number of views of difference scenes.

I am new to GA and as far as my understanding, samsung smart tv app hosts the app in localhost and that can be a problem when using GA.

I have found these maybe-related posts: post1 and post2

The solution from post1 is to use iframe to do the trick, and it works. However for some reasons, I cannot use iframe, so I focus on post2's discussions and solutions.

In post2, the accepted answer bring out two version of GA, and I tried both of them using a dummy localhost html page (For POC purpose). When I check the network, there is a successful request of the 1*1 image, however when I login to GA's admin page, the view number has not changed a bit even in real time analysis.

Sorry for the long background and here's the questions:

  1. Does that mean I have successfully count a page view if there is a request of the 1*1 image?

  2. When registering account of the GA, there is two options: web or mobile app, where web needs you to provide a URL and mobile does not. As my goal is to use GA in a localhost page, I registered the mobile app one, is that correct?

  3. Is there any workaround to use GA in the smart tv app / localhost page without using iframe?

Lastly, here's the script snippet which I place in the last of my head tag.

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_trackPageview']);

    (function() {
         var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async =    true;
         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     })();
</SCRIPT>

This is the same script copied from my other web projects which has a domain and is working (I have verified using the real time analysis, it updated at once so there should not be a problem of sync time lag...) except I add this statement _gaq.push(['_setDomainName', 'none']); which is suggested in post2.

Sorry again if these questions are a bit stupid but I have tried my best to do my research before posting the questions. Anyone can give me some ideas? Thanks!

EDITED I just do another experiment which may provide some more clues: As I mentioned, I have another website which have domain and using GA and it's working.

I just tried edit the source code (exactly the one shown above)and open the page with localhost, and in the GA page (GA web account) real time report still count the view number!

Therefore I suspect is it possible that actually the code works, the request has been sent successfully, and the view has been counted, but the GA report page (I am using mobile account) is not map to my localhost page, so I cannot see any report updates ?

If it is true, I would like to ask 2 more questions:

  1. How does the GA report page map to a specific webpage, or app, in this case, my localhost webpage / smart tv app? By the UA-XXXXX-X only or URL is needed?

  2. As I mentioned I am using the GA mobile account, and seems it cannot show the correct data even if my code is correct and the request successes, what can I do to see the report corresponding to my localhost page? (If I have to register the web version GA account, I have to provide a URL, but mine is localhost/xxx...that's why I registered the mobile one)

Community
  • 1
  • 1
shole
  • 4,046
  • 2
  • 29
  • 69

3 Answers3

0

Yes you can use it on SmartTV, without iframe!

Register for a web version of Google Analytics and when it requests the url put http://localhost.local this should make it track even on localhost!

andrea-f
  • 1,045
  • 9
  • 23
  • Thanks but in fact I have tried it before I post the question, and seems it does not work... – shole Mar 06 '14 at 05:39
0

Or you can create img tag with src

for example:

var image = new Image();
image.src = "http://www.google-analytics.com/__utm.gif?utmwv=1&utmn=2146064995&utmsr=-&utmt=event&utme=5(version*1.003)&utmsc=-&utmul=en-us&utmje=0&utmfl=-&utmac=UA-46810722-3&utmcc=__utma%3D40329076.896209021.1397215722.1398675231.1398844706.4%3B%2B__utmb%3D40329076.9.10.1398844706%3B%2B__utmz%3D40329076.1398844706.2.2.utmccn%3D(direct)%7Cutmcsr%3D(direct)%7Cutmcmd%3D(none)%3B%2B"

this solution works throw all major tv platforms. Samsung, Lg, philips, panasonic.

I had problem with register "http://localhost.local" in the GA, becaouse some Samsung model years worked some other model year did not work.

M.

alfredo86
  • 194
  • 3
0

Smart TV has some issues with google analytics API. Using manual GET/POST method with google API may solve the issue. The following link provides the end point url and parameters for manual GET/POST request.

https://developers.google.com/analytics/devguides/collection/protocol/v1/reference

Hope this may solve your issue. Good luck.

PRASANTH
  • 695
  • 3
  • 15
  • 33