-
Notifications
You must be signed in to change notification settings - Fork 462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: track user's wallet type through user properties #2688
Conversation
Branch preview✅ Deploy successful! https://analytics_user_wallet--walletweb.review-wallet-web.5afe.dev |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Coverage report
Show files with reduced coverage 🔻
Test suite run success962 tests passing in 133 suites. Report generated by 🧪jest coverage report action from 48fa5de |
src/services/analytics/useGtm.ts
Outdated
@@ -79,6 +82,10 @@ const useGtm = () => { | |||
gtmTrackPageview(router.pathname) | |||
}, [router.pathname]) | |||
|
|||
useEffect(() => { | |||
gtmSetUserProperty('walletLabel', walletLabel ?? 'NONE') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create an enum for possible user properties, similar to how to define custom events.
src/services/analytics/useGtm.ts
Outdated
@@ -26,6 +26,12 @@ import { DeviceType } from './types' | |||
import useSafeAddress from '@/hooks/useSafeAddress' | |||
import useWallet from '@/hooks/wallets/useWallet' | |||
|
|||
enum GA_USER_PROPERTIES { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn’t put it here. This hook is just a hook to bind GTM to React. The actual analytics service is where it should be, similar to our custom event definitions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Manu and I checked together how the new property is tracked in ever event. Looks good. |
src/services/analytics/useGtm.ts
Outdated
useEffect(() => { | ||
gtmSetUserProperty(AnalyticsUserProperties.WALLET_LABEL, walletLabel ?? WALLET_LABEL_NONE) | ||
}, [walletLabel]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the wallet is asynchronous, it will inevitably log NONE for the first few events before the wallet (re)connects. I would suggest to not set it at all until the user connects a wallet.
Optionally, we could also unset it when the user disconnects. You migth have to listen to a specific onboard event for that. But to keep things simple I would just keep the last wallet and never unset it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Especially because the interesting interactions such as signing a message / executing a tx will require a wallet anyways.
What it solves
Track the user's used wallet type as user property.
Checklist