Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var allAs = document.querySelectorAll('a');
- allAs.forEach(
- function(el){
- el.addEventListener(
- "mousedown",
- function(){
- dataLayer.push({
- 'event' : 'gtm_link_click',
- 'eventAction' : this.innerText.toLowerCase(),
- 'eventLabel' : this.getAttribute('href').toLowerCase()
- });
- this.removeAttribute('href'); // for testing only so we don't follow links
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement