1 Reply Latest reply on Feb 2, 2015 12:53 PM by DylanGraft

    Edge + Phonegap + Google Analytics = my nightmare

    DylanGraft Level 1

      Has anyone successfully implemented google analytics into a cordova/phonegap app?

       

      My analytics account IS showing me information in the "Real Time" section. But i'm not getting any actual data collection in my overviews section. I've heard varying accounts of how long it takes for this data to come in. Some say an hour, some say weeks. So I'm not sure if I should just wait and see or if I should try to be proactive about it.

       

      Anyway, i'll post some of my process.

       

      I'm using the analytics plugin documented here: danwilson/google-analytics-plugin · GitHub

       

      1) I've added the following to my index.html file:

       

          <script type="text/javascript" charset="utf-8" src="cordova.js"></script>

          <script type="text/javascript" charset="utf-8">

          // Wait for device API libraries to load

          //

          function onLoad() {

              document.addEventListener("deviceready", onDeviceReady, false);

          }

          // device APIs are available

          //

          function onDeviceReady() {

              // Now safe to use device APIs

              window.analytics.startTrackerWithId('UA-XXXXX-XX') omitted actual tracking id

          }

          </script>

       

       

       

      2) I've also added the following to my stage compositonReady event. (not really sure if this is necessary)

       

      window.analytics.startTrackerWithId('UA-XXXXX-XX');

       

       

       

      3) Then on each button event that I want to track I put

       

      window.analytics.trackEvent('Competitor Product', 'Name Of Product');

       

       

       

      Like I said before, it's recognizing the app in real time, but not collecting any data.