How does Mixpanel treat events sent to Mixpanel via CS tracking and Server Side tracking how can I ensure that both are treated as the same session?
Hi event, Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
To answer your question about how Mixpanel treats events sent via client-side (CS) tracking and server-side tracking, and how to ensure they are treated as the same session, I'll provide information based on Mixpanel's documentation.Mixpanel treats client-side and server-side events differently when it comes to user identity and session management. Here's how you can ensure that both are treated as the same session: 1. User Identity Management:
For server-side tracking, Mixpanel doesn't automatically generate IDs. You need to manage the distinct_id yourself. On the client-side, Mixpanel generates a $device_id automatically. To connect these, you should: a) Generate a unique anonymous ID (e.g., UUID) for server-side events.
b) Use this ID as the $device_id for both client-side and server-side events.
c) Once the user is identified, use the same user ID ($user_id) for both client-side and server-side events. Identifying Users (Simplified) provides more details on this approach.2. Session Management:
Mixpanel computes sessions automatically based on the events you send. To ensure client-side and server-side events are treated as the same session, you have a few options: a) Timeout-based sessions (default): Events from both sources will be part of the same session if they occur within the inactivity timeout (default 30 minutes). b) Event-based sessions: Define specific start and end events that can be sent from either client or server. c) Property-based sessions: Use a session_id property on all events (both client-side and server-side) to explicitly define which events belong to the same session. You can configure these options in Project Settings, as mentioned in the Sessions documentation.3. Server-Side Stitching:
Mixpanel offers a feature called Server-Side Stitching that can help associate server-side events with the correct client-side session replays. To use this: - Ensure that your client-side Mixpanel SDK calls identify()
with the user's unique Distinct ID.
- Send the same Distinct ID with your server-side events. This feature is particularly useful for connecting events from multiple sources, as described in the Server Side Stitching documentation.By following these practices, you can ensure that your client-side and server-side events are treated as part of the same user session in Mixpanel. Remember to consistently use the same identifiers ($device_id and $user_id) across both tracking methods for the best results.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.