Skip to content

Commit 9c1a6a2

Browse files
author
Paulo Junior
committed
fix: gtm datalayer props - filter only links
1 parent 07e08c6 commit 9c1a6a2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/utils/addCustomEventListener.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ export const addCustomClickEventListener = (eventName: string) => {
1717
// Try to get the first element with href or action, falls back to the first layer of the clicked element
1818
const targetElement = path.find((el) => !!el.href || !!el.action) || path[0]
1919

20+
// If the element doesn't have href or action we don't need to send it to dataLayer
21+
if (!targetElement.href && !targetElement.action) return
22+
2023
if (!window.dataLayer) {
2124
window.dataLayer = []
2225
}

0 commit comments

Comments
 (0)