Skip to main content

Installation

The Mixpanel JavaScript SDK can be installed via CDN snippet or npm/yarn.
Paste this code snippet right before your closing </head> tag:
Then initialize Mixpanel with your project token:

Track Events

Use mixpanel.track() to send events:

Timing Events

Track how long an action takes:

Identify Users

Do not call identify() for anonymous visitors.
Identify users when they sign in:

Reset on Logout

Clear user data when they log out:

User Profiles

Set profile properties:
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

Resources