File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,16 @@ import { wagmiAdapter } from '@/utils/wagmiConfig';
1414import ChainSelector from '@/components/ChainSelector.vue' ;
1515import './style.css' ;
1616
17+ declare global {
18+ interface Window {
19+ dataLayer : any [ ] ;
20+ axeptioSettings : {
21+ clientId : string ;
22+ cookiesVersion : string ;
23+ } ;
24+ }
25+ }
26+
1727export default {
1828 extends : DefaultTheme ,
1929 Layout,
@@ -33,5 +43,32 @@ export default {
3343 googleAnalytics ( {
3444 id : 'GTM-P7KSD4T' ,
3545 } ) ;
46+
47+ if ( typeof window !== 'undefined' ) {
48+ // Ensure dataLayer exists
49+ window . dataLayer = window . dataLayer || [ ] ;
50+
51+ // Define a map of event types and their corresponding actions
52+ const eventMap = {
53+ connectWallet : 'hw_connectWallet' ,
54+ protectData : 'hw_protectData' ,
55+ grantAccess : 'hw_grantAccess' ,
56+ claimVoucher : 'hw_claimVoucher' ,
57+ } ;
58+
59+ // Add a global click listener
60+ document . addEventListener ( 'click' , ( event ) => {
61+ if ( event . target instanceof Element ) {
62+ // Iterate through eventMap to check which event matches
63+ Object . keys ( eventMap ) . forEach ( ( key ) => {
64+ if ( ( event . target as Element ) . matches ( `[data-track="${ key } "]` ) ) {
65+ window . dataLayer . push ( {
66+ event : eventMap [ key ] ,
67+ } ) ;
68+ }
69+ } ) ;
70+ }
71+ } ) ;
72+ }
3673 } ,
3774} satisfies Theme ;
You can’t perform that action at this time.
0 commit comments