Efficiently track every CTA/link in GA
Created by: bretthayes
What: Instead of adding data attributes to every link/CTA, create a hook with an event listener and some conditions to track every link/CTA click event in GA.
Why:
- To reduce the amount of markup
- To reduce the amount of manual labour
- To track literally every link element/CTA by categorizing events under specific conditions:
- Add
data-category
on parent elements for location categories - Check children element types and class names for button styles
- Add
- To be more efficient and accurate with CTA tracking