Installation
The Mixpanel JavaScript SDK can be installed via CDN snippet or npm/yarn.- CDN Snippet
- npm/yarn
Paste this code snippet right before your closing Then initialize Mixpanel with your project token:
</head> tag:Track Events
Usemixpanel.track() to send events:
Timing Events
Track how long an action takes:Identify Users
Identify users when they sign in:Reset on Logout
Clear user data when they log out:User Profiles
Set profile properties:- set_once()
- increment()
- append()
Set properties only if they don’t exist:
Super Properties
Register global properties included on all events:Group Analytics
Assign users to groups:Privacy Controls
Opt Out of Tracking
EU Data Residency
Disable Geolocation
Debug Mode
Platform Considerations
- Events are sent over HTTPS
- Data is batched and sent every 60 seconds or on page unload
- Cookies persist for 365 days by default
- Works across subdomains by default
- Session Replay requires additional configuration