I'm new to mixpanel, and have just finished my implementation. I'm trying to understand how I can track sessions (if not events or users) without cookie consent - I just need to know the number of sessions on my sites - the same way that GA4 uses the gcd and gcs values to determine consent and model sessions
Hi Matthew M., 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
Mixpanel can track sessions based on the events you send, and it does not require cookies to function—especially if you use server-side tracking or configure the SDK to avoid using cookies/local storage. This flexibility is highlighted as a key advantage over other analytics tools, allowing for cookie-less deployments and privacy-friendly tracking. You can configure Mixpanel to only collect the data you need, and you have full control over whether cookies or local storage are used at all. This is particularly useful for privacy compliance and scenarios where you want to avoid tracking users without consent, but still need aggregate session counts for analytics purposes.Key points for your use case:Important Limitation:
If you fully disable cookies/local storage and do not provide your own session or user identifiers, Mixpanel will treat each page load as a new anonymous user/session. This means your session counts may be inflated (one per page load), similar to how GA4 models sessions in the absence of consent. If you want more accurate session grouping without cookies, you would need to implement your own logic for session continuity (e.g., via server-side identifiers or short-lived tokens).Summary: You can track the number of sessions on your site in Mixpanel without cookie consent by either using server-side tracking or disabling persistence in the SDK. However, without any identifier, each page load will be counted as a new session, which is similar to how GA4 handles sessions when consent is not given. For more nuanced session tracking without cookies, you would need to implement your own session logic see privacy-friendly tracking and blog on cookies and GDPR.
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.
kapa.ai how do I set a $device_id when initializing the mixpanel instance?
Let me check the knowledge base for you again. One moment! 📚
To set a $device_id when initializing the Mixpanel instance, you should include it as a property on your events, rather than as a direct configuration option during initialization. For projects using the Simplified ID Merge system, you send events with a $device_id property to represent the anonymous user or device. When you later know the user's identity, you send both $device_id and $user_id in the same event to trigger identity merging.Example (server-side, Simplified ID Merge)::**LBKS```LBKS{
"event":: "View Anonymous Page",
"properties": {
"token": "{{token}}",
"$device_id": "anonymous111"
}
}When the user logs in: {
"event": "Sign Up",
"properties": {
"token": "{{token}}",
"$device_id": "anonymous111",
"$user_id": "charlie"
}
}```Mixpanel will automatically use $device_id as the distinct_id if $user_id is not present, and will merge identities when both are present in the same event Understanding Simplified ID Merge.Note:**
- The $device_id is not set as a configuration parameter during SDK initialization, but is included as a property on each event you send.
- If you are using a client-side SDK, Mixpanel will automatically generate a $device_id for you unless you override it by registering your own value as a super property or by sending it explicitly with each event.If you need to ensure a specific $device_id is used, you must manually add it to your event properties when tracking events Server-side Identity Management (Simplified).If you need more specific code examples for a particular SDK (JavaScript, Swift, etc.), please specify which one you are using.
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.
kapa.ai if I do this, then how are autocapture events linked to the $device_id I've set?
Let me check the knowledge base for you again. One moment! 📚
When using the Mixpanel JavaScript SDK, the $device_id is automatically generated and managed by the SDK, and it is attached to all events—including Autocapture events—by default. If you want to override the default $device_id (for example, to align it with an external identifier or a value from another system), you need to register your custom $device_id using the mixpanel.register() method after initializing Mixpanel.Here’s how you can do it: js mixpanel.init('YOUR_PROJECT_TOKEN', { autocapture: true });LBKS// Override the default $device_id mixpanel.register({ $device_id: 'your_custom_device_id' });LBKSAfter you register your custom $device_id, all subsequent events—including Autocapture events—will use this value for $device_id and link the events accordingly. This ensures that Autocapture events are associated with the $device_id you have set, not the one automatically generated by the SDK Setting up Autocapture with Segment.Important:
- You must call mixpanel.register({ $device_id: ... }) before any events are sent (including Autocapture events) to ensure all events use your custom $device_id.
- If you register the $device_id after some events have already been sent, only subsequent events will use the new value.This approach is commonly used when integrating with other systems (like Segment) to ensure consistent identity across platforms.If you do not manually set $device_id, the SDK’s auto-generated value will be used for all events, including Autocapture Autocapture JavaScript SDK.
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.
kapa.ai how do I set the initial UTM medium on a user property?
Let me check the knowledge base for you again. One moment! 📚
To set the initial UTM medium as a user property in Mixpanel, you generally do not need to do anything manually if you are using the JavaScript SDK with default settings. Mixpanel will automatically capture UTM parameters (including utm_medium) from the URL on a user's first visit and store them as user profile properties prefixed with initial_ (e.g., initial_utm_medium). This property represents the first-touch attribution and will persist on the user profile for future reference see FAQ, Web Attribution.How it works:
- When a user first visits your site with a UTM parameter in the URL (e.g., ?utm_medium=email), Mixpanel will automatically set initial_utm_medium on their user profile.
- No extra configuration is needed for this automatic first-touch tracking if you are using the default SDK settings and identifying users normally.If you are using a server-side implementation or a third-party integration, you must manually set these UTM properties on the user profile using the appropriate method (e.g., people.set or the Engage API) see FAQ.Summary:
- Client-side (JavaScript SDK): Automatic—no manual action required.
- Server-side: Manually set initial_utm_medium as a user property when you detect it.For more details, see the documentation on default user properties and UTM tracking.
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.
kapa.ai what's happened to metric trees? they're no longer an option to create, have they been disabled? I'm on the enterprise plan
Let me check the knowledge base for you again. One moment! 📚
I'm sorry, but the knowledge sources do not contain any information about Metric Trees being disabled or removed as an option to create, even for Enterprise plan users. All available documentation and blog posts describe Metric Trees as an active, premium feature for Enterprise customers, with no mention of deprecation or discontinuation Docs: Metric Tree.If you are unable to access Metric Trees despite being on the Enterprise plan, it may be a temporary issue or a change not reflected in the current documentation. I recommend reaching out directly to Mixpanel support or your account representative for clarification and assistance.
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.
kapa.ai I send an event to mixpanel called "purchase" that contains the total revenue for that purchase. As purchases can be in different currencies, I also pass the exchange rate into GBP. How do I calculate a metric at event level that will give by the total revenue in GBP for that purchase event?
