You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use Mixpanel to track user actions across my web application. But I have no idea how to integrate it into a Remix application. I need to initialize a mixpanel object and then use it to track. I want to do it once. So, can I do it in entry.client.tsx? Or I have to make a .ts file where I initialize and export the mixpanel object? What's the right way to do this?
At the moment I do this in a mixpanel.ts file and then import track wherever I need:
import {PropertyDict} from 'mixpanel'
import mixpanel from 'mixpanel-browser'
if (window.location.hostname !== 'localhost') {
mixpanel.init('dummy', {track_pageview: 'url-with-path', persistence: 'localStorage'})
}
export function track(event: string, data: PropertyDict) {
mixpanel.track(event, data)
}
Is this OK?
If I want to track all page views, do I add it to entry.client.tsx? Is this enough?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I want to use Mixpanel to track user actions across my web application. But I have no idea how to integrate it into a Remix application. I need to initialize a
mixpanel
object and then use it to track. I want to do it once. So, can I do it inentry.client.tsx
? Or I have to make a.ts
file where I initialize and export the mixpanel object? What's the right way to do this?At the moment I do this in a
mixpanel.ts
file and then importtrack
wherever I need:Is this OK?
If I want to track all page views, do I add it to
entry.client.tsx
? Is this enough?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions