0

Hi I have been attempting to integrate google analytics with my hybrid mobile app witch is developed with durandal and phonegap.This is what I have done so far:

I have copyed the piece of code generated by google analytics and have added it in my parent html file.The code looks like this and I have checked the source to be sure it is loaded:

   <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
        _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>

I then linked to the durandal route complete event like this:

 vm.router.on('router:navigation:complete').then(function (instance) {
         window._gaq.push(['_trackPageview', location.pathname + location.search + location.hash]);
    });

This piece of code get's executed every time the page gets changed.

I then started navigating around the app and after half an hour still no data has been displayed on the analytics page.

I have checked the applications in chrome dev tool to see if any call have meed made to google and none get displayed.

Does anyone know what I am doing wrong?

EDIT

From the docs I realized that I had to set my domain to none in order for the calles to google analytics to take place:

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

I am assumint this is the correct way to go because this will be a hybrid app that will run on many different tablets.Can anyone validate this pls?

aleczandru
  • 5,319
  • 15
  • 62
  • 112

1 Answers1

0

Your problem is going to be what location.pathname and location.search actually produces in an app. On a page served from a web server, this will be obvious, but from a PhoneGap app???

Try this out in a simulator and print the values out to screen - maybe you'll find the answer that way.

Also, why are you using traditional Google Analytics? Using Google Universal Analytics seems much better suited to your needs as that caters better for mobile app development.

dvdsmpsn
  • 2,839
  • 1
  • 26
  • 40