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

Then, in deviceready add the following:


And for each event, simply:

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

Job done. Big-up to Dan Wilson!

Tuesday, 1 April 2014

Leaflet.js clickable marker label

I couldn't find any documentation or examples on how to make a label clickable in leaflet.js.

I tried adding a myLabel.on('click',function(){ }); event but it simply wasn't working. After poking around in the console for a while and logging the label object I found you need to change a seemingly undocumented 'clickable' option. So I ended up with something like this:

var myLabel = myMarker.label;
myLabel.options.clickable = true;
//do your stuff