From 635b5c000833ff65d4498413777323b70022be29 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Tue, 21 Nov 2023 15:39:00 +0100 Subject: [PATCH] Analytics: track wallet address --- src/services/analytics/types.ts | 1 + src/services/analytics/useGtm.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/services/analytics/types.ts b/src/services/analytics/types.ts index 47fb97dbb6..07c3c4a59b 100644 --- a/src/services/analytics/types.ts +++ b/src/services/analytics/types.ts @@ -32,4 +32,5 @@ export enum DeviceType { export enum AnalyticsUserProperties { WALLET_LABEL = 'walletLabel', + WALLET_ADDRESS = 'walletAddress', } diff --git a/src/services/analytics/useGtm.ts b/src/services/analytics/useGtm.ts index f2fc484de3..854a63741e 100644 --- a/src/services/analytics/useGtm.ts +++ b/src/services/analytics/useGtm.ts @@ -37,7 +37,7 @@ const useGtm = () => { const isTablet = useMediaQuery(theme.breakpoints.down('md')) const deviceType = isMobile ? DeviceType.MOBILE : isTablet ? DeviceType.TABLET : DeviceType.DESKTOP const safeAddress = useSafeAddress() - const walletLabel = useWallet()?.label + const wallet = useWallet() // Initialize GTM useEffect(() => { @@ -83,10 +83,16 @@ const useGtm = () => { }, [router.pathname]) useEffect(() => { - if (walletLabel) { - gtmSetUserProperty(AnalyticsUserProperties.WALLET_LABEL, walletLabel) + if (wallet?.label) { + gtmSetUserProperty(AnalyticsUserProperties.WALLET_LABEL, wallet?.label) } - }, [walletLabel]) + }, [wallet?.label]) + + useEffect(() => { + if (wallet?.address) { + gtmSetUserProperty(AnalyticsUserProperties.WALLET_ADDRESS, wallet?.address) + } + }, [wallet?.address]) // Track meta events on app load useMetaEvents()