Last active
May 30, 2019 12:00
-
-
Save nickpettican/38ab39e6bc5921b11a681fb9fb6f0ac8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addNavTracking() { | |
let parentNavs = document.querySelectorAll(".header-navigation li.menu-item"); | |
if (parentNavs.length) { | |
parentNavs.forEach(item => { | |
let label = item.querySelector("a").textContent; | |
if (label) { | |
item.addEventListener("click", () => { | |
ga("send", "event", "Menu-Nav", "click", label); | |
}); | |
} | |
}); | |
} | |
} | |
addNavTracking(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment