I would like to add analytics.js click tracking to some elements on a page which all have a unique data- attribute.
On the anaytics page :
https://developers.google.com/analytics/devguides/collection/analyticsjs/events
It says to add the code in the following format :
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
Although when for instance it says eventCategory the example it gives is just "Video" rather than a class or id.
My question is how would i right the above so it tracks each element based on its data attribute for instance : data-id="2250ee774b0a42688745b6143b662328"
Any help would be greatly appreciated.
Thanks
David
you should use https://sizzlejs.com/ to find the selector based on data-id and write custom code.
But why not use this tool to record your actions without going through this hassle.
www.customerlabs.co checkout their action recorder.