mixpanel / mixpanel-js

Official Mixpanel JavaScript Client Library
https://mixpanel.com/help/reference/javascript
Other
888 stars 312 forks source link

mixpanel.track_pageview does not send any event #418

Closed hhugom closed 9 months ago

hhugom commented 9 months ago

"mixpanel-browser": "2.49.0"

We are currently using mixpanel in a SPA and we were trying to use mixpanel.track_pageview to track user's navigation throughout our application but it does not seem to send any event to mixpanel despite sending other events without any problems.

We use react so we call mixpanel.track_pageview inside a hook at the top of our highest level component, the function is correctly called but there is no event dispatched by mixpanel afterward (no log client side and no visibile event either on mixpanel's client)

export const useTrackPageView = (page: string): void => {
  useEffect(() => {
    mixpanel.track_pageview({ page });
  }, []);
};

Thanks for the help!