Skip to content
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

Cannot add event properties to Page View event when track_pageview: true in SPA #415

Open
anniegiang-octave opened this issue Feb 7, 2024 · 1 comment

Comments

@anniegiang-octave
Copy link

I have a Next.js app. I am tracking the Page View event using track_pageview: true in mixpanel.init, as well as a custom useEffect hook that listens for route changes and tracks using mixpanel.track_pageview() (since Next.js is SPA).

The event props are added on route changes when the props are added to mixpanel.track_pageview(customProps). But the props are not added to the Page View event that's fired from track_pageview: true when the app first loads.

Is there a way to add event props to the Page View event that it is fired from track_pageview: true?

"next": "13.5.6",
"mixpanel-browser": "2.48.1",
"react": "18.2.0",
@chiyc
Copy link
Contributor

chiyc commented Feb 8, 2024

Thanks for sharing your use case. It sounds like it may be easier here to fire the initial Page View event manually with the customProps right after SDK initialization instead of using track_pageview: true. Would that be possible in this situation?

mixpanel.init({ track_pageview: false, /* other options */ })
mixpanel.track_pageview(customProps)

I have a few other questions about the customProps. Where do the values in customProps come from? Are they known constant values ahead of time or are they only known once the page loads? Do they change between your calls to mixpanel.track_pageview(customProps)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants