Send Events from Web
Last updated
Was this helpful?
Was this helpful?
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
// Route events from Mixpanel’s SDKs via a proxy in your own domain - prevents adblockers impacting tracking.
// See more: https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-via-proxy
api_host: "YOUR_PROXY_URL",
});
const account = useAppSelector(userSelectors.getAuthUser)
const linkedEvmWallet = useAppSelector(
userSelectors.getEvmLinkedWalletAddress,
)
const profile = useAppSelector(userSelectors.getProfile)
useEffect(() => {
if (account?.uid) {
mixpanel.identify(account.uid)
mixpanel.people.set({
$email: account.email,
$name: profile?.username,
$avatar: profile?.profilePictureUrl,
// Optional: example of including a user's wallet in their user profile
wallet: linkedEvmWallet,
userId: account.uid,
})mixpanel.track("Joined Experience", {
"Joined Experience Name": worldId,
})