Skip to main content
Unity SDK does not currently support Simplified ID Merge.

Installation

1

Add to manifest

Add to ./Packages/manifest.json:
{
  "dependencies": {
    "com.mixpanel.unity": "https://github.com/mixpanel/mixpanel-unity.git#master"
  }
}
Or specify a version:
"com.mixpanel.unity": "https://github.com/mixpanel/mixpanel-unity.git#v3.5.1"
2

Configure in Unity

  1. Open Edit → Project Settings → Mixpanel
  2. Enter your project token
  3. Click Save
3

Import and use

using mixpanel;

Mixpanel.Track("Game Started");
Supports Unity 2018.3+ with .NET 4.x or higher.

Track Events

var props = new Value();
props["level"] = 5;
props["character"] = "Warrior";
props["score"] = 1500;

Mixpanel.Track("Level Completed", props);

Timing Events

Mixpanel.StartTimedEvent("Level Duration");

// Player completes level
Mixpanel.Track("Level Duration");
// Duration property added automatically

Flush Events

// Flush immediately
Mixpanel.Flush();
Adjust flush interval in Edit → Project Settings → Mixpanel.

Identify Users

Mixpanel.Track("sign in");
Mixpanel.Identify("12345");

Reset on Logout

Mixpanel.Track("log out");
Mixpanel.Reset();

User Profiles

Mixpanel.Identify("12345");
Mixpanel.People.Set("Plan", "Premium");

// Set multiple properties
var props = new Dictionary<string, object> {
  { "level", 10 },
  { "class", "Warrior" },
  { "vip", true }
};
Mixpanel.People.Set(props);
Mixpanel.People.SetOnce("First Game", DateTime.Now.ToString());

Super Properties

Mixpanel.Register("game_version", "2.0.1");
Mixpanel.Register("platform", "Unity");

// Register without overwriting
Mixpanel.RegisterOnce("first_launch", DateTime.Now.ToString());

Group Analytics

// Set group
var props = new Value();
props["guild"] = "Warriors Guild";

Mixpanel.Track("Quest Completed", props);

// Add to user profile
Mixpanel.Identify("12345");
Mixpanel.People.Set("guild", "Warriors Guild");

Privacy Controls

Opt Out

Mixpanel.OptOutTracking();

// Opt back in
Mixpanel.OptInTracking();

// Initialize with opt-out
MixpanelStorage.IsTracking = false;

EU/India Data Residency

Configure in Edit → Project Settings → Mixpanel:
  • EU: Set API Host Address to https://api-eu.mixpanel.com/
  • India: Set API Host Address to https://api-in.mixpanel.com/

Debug Mode

Enable in Unity Project Settings → Mixpanel or:
// View logs in Unity console

Platform Considerations

  • Works on all Unity platforms (iOS, Android, WebGL, Desktop)
  • Events flush every 60 seconds (configurable)
  • Super properties persist in local storage
  • Supports both 2D and 3D games
  • Compatible with Unity’s IL2CPP backend
For manual initialization, select “Manual Initialization” in settings and call Mixpanel.Init().

Resources

Build docs developers (and LLMs) love