Friday, 11 April 2014

Google analytics event tracking in PhoneGap / Cordova

I spent (wasted) hours trying to get this GAPlugin to work but simply couldn't. So I went back to square one, did some more googling and found Dan Wilson's Google Analytics Plugin. I'm pleased to say I had it running in minutes simply by following his concise instructions:

cordova plugin add https://github.com/danwilson/google-analytics-plugin.git

Then, in deviceready add the following:

analytics.startTrackerWithId('UA-XXXX-YY') 

And for each event, simply:

analytics.trackEvent('Category', 'Action', 'Label', Value) 

Job done. Big-up to Dan Wilson!

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!