This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Mixpanel JavaScript SDK Cheatsheet

A quick reference guide for the Mixpanel JavaScript library: user identification, user profile properties, super properties, and event tracking.

· Published

Mixpanel provides event analytics and behavioral telemetry for web and mobile applications.

Initialization

import mixpanel from 'mixpanel-browser';

mixpanel.init('YOUR_PROJECT_TOKEN', {
  debug: false,
  track_pageview: true,
  persistence: 'localStorage'
});

User Identification & Profiles

// Link an anonymous session to a registered user ID
mixpanel.identify('user_1024');

// Set profile attributes on People
mixpanel.people.set({
  $name: 'Alice Cooper',
  $email: '[email protected]',
  plan: 'Enterprise',
  team_size: 15
});

// Increment numeric properties
mixpanel.people.increment('login_count');

Super Properties

Super properties persist across sessions and attach automatically to every subsequent event:

// Register persistent properties
mixpanel.register({
  app_version: '2.4.0',
  tier: 'premium'
});

// Register only if not already set
mixpanel.register_once({
  first_touch_campaign: 'google_ads'
});

Event Tracking

// Basic event
mixpanel.track('Sign Up Clicked');

// Event with structured metadata
mixpanel.track('Purchase Completed', {
  product_id: 'prod_99',
  category: 'Subscription',
  price: 49.99,
  currency: 'USD'
});

// Reset user session on logout
mixpanel.reset();

References

Related topics