Home > Uncategorized > Using Google Analytics in Phonegap apps.

Using Google Analytics in Phonegap apps.

GoogleAnalytics If you use Phonegap, and want to know how many people use your app regularly, and where they come from, then Google Analytics, with a small modification, is great for this purpose. – But you need a slight modifiction to the normal tracking code.

Firstly, download the ga.js file from http://www.google-analytics.com/ga.js – open it in a text editor and look for the word file:, and replace it with _file then stick it into your www folder. make a reference to it from every page you want to track, then use the script:

<script type="text/javascript" src="ga.js"></script>
    <script>
 var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-YOUR_ID_HERE']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_trackPageview', 'NAME_OF_PAGE']);
    </script>

To get your UA-ID then you have to go to Google Analytics, create a new property – selecting “WEBSITE” not “APP”, and pick it out of the code.

To test it, then you run the app, and look at Google Analytics “Real time”, if you see activity appearing, then it’s working!

Categories: Uncategorized
  1. December 1, 2014 at 8:40 am

    Does not work for me

    Like

  1. No trackbacks yet.

Leave a reply to peyman Cancel reply