我一直在使用Google Analytics来跟踪我的移动应用程序使用情况。我用Rhomobile(类似于Phonegap)构建了它,它使用WebView
来显示UI。我在第一页粘贴了Google Analytics的javascript代码,它在iOS4到6和Android 2.3及更低版本上运行良好。但是,不会报告任何Android 4 +设备的统计信息。我的应用程序可以访问互联网。有什么想法吗?Android 4 是否阻止了 Google Analytics 的这种使用?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-Y']);
_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>
我想通了。您需要添加:
_gaq.push(['_setDomainName', 'none']);
以前
_gaq.push(['_trackPageview']);
它至少可以在安卓 4.1.1 上运行。