Skip to content

Commit

Permalink
Analytics: track wallet address
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 21, 2023
1 parent 09a88f6 commit 635b5c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/services/analytics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export enum DeviceType {

export enum AnalyticsUserProperties {
WALLET_LABEL = 'walletLabel',
WALLET_ADDRESS = 'walletAddress',
}
14 changes: 10 additions & 4 deletions src/services/analytics/useGtm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 635b5c0

Please sign in to comment.