Google Analytics in Cordova App - need some high level direction, pls?

Hi, I am pretty new to Google Analytics (GA). Adding Google analytics to your site/app seems pretty easy (you just include some JS) and I have this working for my browser based site. I also see some plugins like https://atmospherejs.com/reywood/iron-router-ga that I have not had time to play with yet.

Anyway, for mobile, as Cordova is kinda hitting the same site I was wondering how we should be integrating with GA on that front. Google has a separate API for iOS, Android etc I wanted to check if the best practice for Meteor/Cordova is to ignore that and go with a plugin like : https://github.com/danwilson/google-analytics-plugin ?

Any recommendations etc welcome. thanks

Hi,

I have used the Google Analytics Cordova-plugin on non-meteor projects before, and now switching to Meteor for production use. With a quick test, that plugin seems to work fine in Meteor, as long as you request it inside a Meteor.isCordova-check.

I just set up the Iron Router ga-plugin for analytics mobile app. I can keep you posted on the results. The plugin worked great for website tracking, but that did not work inside the Cordova wrapper, so I switched from website to mobile app analytics.

i havent: noticed problems when running inside cordova, what issues did you have?

The app did not send data to Analytics, even when it was deployed on a live server. Haven’t gotten any mobile analytics data yet, but I just set up the plugin.

Did you set up an access rule inside mobile-config.js to allow the data to be sent? If this is the problem I think you will see errors in the console for URL access failures.

I actually needed two access rules. One to allow the .js to be fetched and the other to allow data to be sent.

// source for analytics.js
App.accessRule('http://www.google-analytics.com/*',{external:false});

// destination for data
App.accessRule('https://stats.g.doubleclick.net',{external:false});
2 Likes

Thanks folks.

@vtntimo have you seen any data sent from Cordova yet?

@dcsan My issue was I did not see anything (but I was not using the plugin at that time).
@mikowals yep, I think that could be my issue… waiting to see what stats I get now.

@adamgins @mikowals I did not get it to work. I have the access rules and everything set up correctly I believe, I am getting data from the web version of the app but no data from the Cordova app. I’m guessing website analytics is just not the right way to go and instead one should use mobile app analytics? That is bit of a problem, as it does not work with the web version :frowning:

EDIT: I f*cked up. Forgot those access rules after all…