Skip to content

Instantly share code, notes, and snippets.

@joseacat
Created February 19, 2024 16:40
Show Gist options
  • Save joseacat/a3b0ba7053f5fedfb2cab1639192e9d1 to your computer and use it in GitHub Desktop.
Save joseacat/a3b0ba7053f5fedfb2cab1639192e9d1 to your computer and use it in GitHub Desktop.
Ejemplo Datalayer
const botones_menu = document.querySelectorAll(".drl-menu-item");
botones_menu.forEach((item) => {
item.addEventListener("click", () => {
const label_item = item.querySelector("span").textContent;
const text_item = label_item.replace(/\s+/g, "_");
dataLayer.push({
event: "custom_click",
event_category: "header",
event_action: "menu",
event_label: label_item,
clicked_text: text_item,
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment