3

I've been using Google Analytics to track my mobile app usage. I built it with Rhomobile (similar to Phonegap) and it uses a WebView to display the UI. I pasted the Google Analytics javascript code in the first page and it works perfectly fine on iOS4 to 6 and Android 2.3 and less. However, no stats are reported for any Android 4+ devices. My app has Internet access. Any ideas? Is Android 4 blocking this usage of 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>
joao2fast4u
  • 6,868
  • 5
  • 28
  • 42
fnllc
  • 3,047
  • 4
  • 25
  • 42
  • I'd really like to know this too. It's hosing us up bigtime! – drogon Nov 19 '12 at 20:32
  • I'm going to try this and see if it works: http://www.the4thdimension.net/2011/11/using-google-analytics-with-html5-or.html – fnllc Nov 25 '12 at 10:54

1 Answers1

1

I figured it out. You need to add:

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

before

_gaq.push(['_trackPageview']);

and it will work on Android 4.1.1 at least.

fnllc
  • 3,047
  • 4
  • 25
  • 42