Page 1 of 1

I'm facing issues with enabling Google analytics on my app. Need help

Posted: Mon May 11, 2015 11:02 am
by devapp

I've created a .js file with the following code:
var _gaq = _gaq || [];
//Note: you should replace this value with your personal site data.
gaq.push(['setAccount', 'UA-62826163-1']);
gaq.push(['trackPageview']);
//Add event handler on page show.
var onPageShow = function(){
//Track page into GA when it has been shown
gaq.push(['trackPageview', window.location.href]);
};
jQuery(document).bind("pageshow", onPageShow);
(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);
})();

Do I need to add any event on pages after this?


I'm facing issues with enabling Google analytics on my app. Need help

Posted: Mon May 11, 2015 7:43 pm
by Evgene Karachevtsev

I'm facing issues with enabling Google analytics on my app. Need help

Posted: Tue May 12, 2015 7:21 am
by devapp

Yes, I've seen the tutorials. I just want to tack the pages on an Android app, that's it. Should I use the following code and add it as .js file?

var initGA = function() {
console.log('Initialize GA');
if (getGAPlugin()) {
getGAPlugin().init(gaSuccessHandler, gaErrorHandler, "ENTER_YOUR_GOOGLE_ANALYTICS_ID_HERE", 10);
}
};

var trackPage = function(pageName) {
console.log("trackPage: " + pageName);
if (getGAPlugin()) {
getGAPlugin().trackPage(gaNativePluginResultHandler, gaNativePluginErrorHandler, pageName);
}
};

var trackEvent = function(category, eventAction, eventLabel, eventValue) {
console.log("trackEvent: " + category);
if (getGAPlugin()) {
getGAPlugin().trackEvent(gaNativePluginResultHandler, gaNativePluginErrorHandler, category, eventAction, eventLabel, eventValue);
}
};

Then add an event handler on every page?

trackPage('pagename');


I'm facing issues with enabling Google analytics on my app. Need help

Posted: Wed May 13, 2015 11:53 am
by Serhii Kulibaba

Hello,

Yes, use that JS in your app.