我想在我的应用程序中包括谷歌分析。
代码如下:
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 但它不起作用。你能指导我使用这个吗?
发布于 2016-02-03 08:12:51
TVML不支持在您的模板中内联JS的script标记。
相反,您应该在主JS文件(其中包含App.onLaunch)中包含JS脚本。
请注意,TVML/TVJS没有“页面”,因此页面查看不会像在web上那样跟踪。此外,Javascript环境与浏览器不同,有些API不可用,因此Google Analytics库可能无法与TVJS一起使用。
https://stackoverflow.com/questions/35147953
复制相似问题