Skip to content

Commit 4428c46

Browse files
author
Paulo Júnior
authored
fix: add gtm prefix to dataLayer props so they can be properly mapped
1 parent 899308c commit 4428c46

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/utils/addCustomEventListener.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ export const addCustomClickEventListener = (eventName: string) => {
2828
window.dataLayer.push({
2929
event: eventName,
3030
gtm: {
31-
element: targetElement,
32-
elementId: targetElement.id || '',
33-
elementClasses: targetElement.className || '',
34-
elementUrl: targetElement.href || targetElement.action || '',
35-
elementTarget: targetElement.target || '',
36-
clickUrl: targetElement.href || targetElement.action || '',
37-
clickText: targetElement.textContent || '',
38-
originalEvent: event,
31+
'gtm.element': targetElement,
32+
'gtm.elementId': targetElement.id || '',
33+
'gtm.elementClasses': targetElement.className || '',
34+
'gtm.elementUrl': targetElement.href || targetElement.action || '',
35+
'gtm.elementTarget': targetElement.target || '',
36+
'gtm.elementText': targetElement.textContent || '',
37+
'gtm.originalEvent': event,
3938
inShadowDom: shadowFound,
4039
},
4140
})

0 commit comments

Comments
 (0)