Skip to content

Commit 3cf77a6

Browse files
author
Paulo Júnior
authored
fix: gtm datalayer props
1 parent 4428c46 commit 3cf77a6

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ npm-debug.log*
2424
yarn-debug.log*
2525
yarn-error.log*
2626

27+
28+
.idea/

src/utils/addCustomEventListener.ts

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

0 commit comments

Comments
 (0)