I’m trying to use Dan Wilson’s Google Analytics plugin but can’t seem to get it to pull any data in. He says to place the UA code in the deviceready handler. Would that be something like this for Ionic?
That would be the correct place to put it, so if it’s not working I would suggest trying it with just deviceready outside of angular and narrowing it down.
I am trying to add Google analytics to my app too. Could you share the code that you use to call the startTrackerWithId()? I tried a few options but I am still getting “Google Analytics plugin could not be loaded.”
Here’s how I have mine. Also note that this function only works on deployed apps due to it being installed as a plugin so you’ll always get the else statement until you build and deploy the app.
Hey guys,
thanks to this thread I managed to have the plugin to work.
There is still one thing I can’t figure out myself, where in the angular routing process should I indicate that user changed view ?
In other words, where should I put this : analytics.trackView(‘name-of-template’);
if I want to track each template ?
hey i am always getting an (analytics is not defined) ‘Google Analytics plugin could not be loaded’ please help me, how to make it work.
i used the following code.
if (typeof analytics !== ‘undefined’){
analytics.startTrackerWithId(‘UA-xxxxxxxx-x’);
analytics.trackView(‘newhome-2’);
console.log(“starting analytics”);
analytics.debugMode();
}
else
{
console.log(“Google Analytics plugin could not be loaded.”);
}
i have included this code in $ionicPlatform.ready function.
please help me out.