2 Replies Latest reply on Sep 13, 2016 9:53 PM by Mark Nongkhlaw

    Extension for Google Anaytics

    Fernando Coelho da Silva

      Someone already wrote some native extension for iOS and Android for Google Anaytics that you can share?

      Using the following parameters takes too long to load on application startup:

        var _gaq = _gaq | | [];
              _gaq.push (['_setDomainName', 'none']);
              _gaq.push (['_setAccount', 'UA-xxxxxx-x']);
              _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>


        • Re: Extension for Google Anaytics
          Jon Tara

          There's no possibility of an extension, and it wouldn't help even if there was.


          Google Analytics uses a Javascript API. They don't provide any alternative API that native code would be able to use. Their Terms and Conditions require that you load their Javascript from from their server for every session. You are not allowed to store a local copy of the Javascript, and that would be difficult in any case, because of Google's dynamic Javascript loader.


          The delay you see if almost certainly due to having to load the script from the Google server.


          You will have to somehow deal with the possibility that the device is off-line and has no Internet access. If your app hangs in this situation, Apple will reject it from the App Store.


          You need to carefully think-out your use of online APIs like Google Analytics, Google Maps, etc. and make sure that they don't interfere with offline use.


          You're creating a native app, not a website!


          You might want to research other analytic services that are more well-suited for use with mobile apps.