【问题标题】:How to add code google analytics with tvml, tvjs如何使用 tvml、tvjs 添加代码谷歌分析
【发布时间】:2016-02-02 08:01:39
【问题描述】:

我想在我的应用中包含谷歌分析。

这里代码:

var return_doc  = `<?xml version="1.0" encoding="UTF-8" ?>           
<document>  
                            <head>  
                              <script type="text/javascript">  
                              var _gaq = _gaq || [];  
                              _gaq.push(['_setAccount', 'UA-XXXXXXXX']);  
                              _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);  
                              })();  
                              function timerTracking()  
                              {  
                                  _gaq.push(['_trackPageview'])  
                                  t=setTimeout("timerTracking()",900000);  
                              }  
                              timerTracking();  
                            </script>  
                            <style>  

                            </style>  
                            </head>  
                            <stackTemplate  

但它不起作用。 你能指导使用这个吗?

【问题讨论】:

    标签: tvos tvml tvjs


    【解决方案1】:

    TVML 不支持在模板中内联 JS 的脚本标签。

    相反,您应该将 JS 脚本包含在您的主 JS 文件中(您有 App.onLaunch)。

    请注意,TVML/TVJS 没有“页面”,因此不会像在网络上那样跟踪页面浏览量。此外,Javascript 环境与浏览器不同,有些 API 不可用,因此 Google Analytics 库可能无法与 TVJS 一起使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      • 1970-01-01
      • 2017-09-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多