Android Web应用中的Google Analytics无法在4.0或更高版本中运行

时间:2012-11-16 11:08:01

标签: android google-analytics android-webview

我一直在使用Google Analytics来跟踪我的移动应用使用情况。我使用Rhomobile构建它(类似于Phonegap),它使用WebView来显示UI。我在第一页上粘贴了Google Analytics javascript代码,它在iOS4到6和Android 2.3及更低版本上运行得非常好。但是,没有针对任何Android 4+设备报告的统计信息。我的应用可以访问Internet。有任何想法吗? 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>

1 个答案:

答案 0 :(得分:1)

我明白了。你需要添加:

_gaq.push(['_setDomainName', 'none']);

_gaq.push(['_trackPageview']);

它至少可以在Android 4.1.1上运行。