> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/mixpanel/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Unity SDK

> Track events from Unity games with the Mixpanel Unity SDK

<Warning>
  Unity SDK does not currently support Simplified ID Merge.
</Warning>

## Installation

<Steps>
  <Step title="Add to manifest">
    Add to `./Packages/manifest.json`:

    ```json theme={null}
    {
      "dependencies": {
        "com.mixpanel.unity": "https://github.com/mixpanel/mixpanel-unity.git#master"
      }
    }
    ```

    Or specify a version:

    ```json theme={null}
    "com.mixpanel.unity": "https://github.com/mixpanel/mixpanel-unity.git#v3.5.1"
    ```
  </Step>

  <Step title="Configure in Unity">
    1. Open Edit → Project Settings → Mixpanel
    2. Enter your project token
    3. Click Save
  </Step>

  <Step title="Import and use">
    ```csharp theme={null}
    using mixpanel;

    Mixpanel.Track("Game Started");
    ```
  </Step>
</Steps>

<Info>
  Supports Unity 2018.3+ with .NET 4.x or higher.
</Info>

## Track Events

```csharp theme={null}
var props = new Value();
props["level"] = 5;
props["character"] = "Warrior";
props["score"] = 1500;

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

### Timing Events

```csharp theme={null}
Mixpanel.StartTimedEvent("Level Duration");

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

### Flush Events

```csharp theme={null}
// Flush immediately
Mixpanel.Flush();
```

Adjust flush interval in Edit → Project Settings → Mixpanel.

## Identify Users

```csharp theme={null}
Mixpanel.Track("sign in");
Mixpanel.Identify("12345");
```

### Reset on Logout

```csharp theme={null}
Mixpanel.Track("log out");
Mixpanel.Reset();
```

## User Profiles

```csharp theme={null}
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);
```

<Tabs>
  <Tab title="SetOnce()">
    ```csharp theme={null}
    Mixpanel.People.SetOnce("First Game", DateTime.Now.ToString());
    ```
  </Tab>

  <Tab title="Increment()">
    ```csharp theme={null}
    Mixpanel.People.Increment("games_played", 1);
    Mixpanel.People.Increment("total_score", 1500);
    ```
  </Tab>

  <Tab title="Append()">
    ```csharp theme={null}
    Mixpanel.People.Append("achievements", "First Victory");
    ```
  </Tab>

  <Tab title="Union()">
    ```csharp theme={null}
    Mixpanel.People.Union("classes_played", "Warrior");
    ```
  </Tab>
</Tabs>

## Super Properties

```csharp theme={null}
Mixpanel.Register("game_version", "2.0.1");
Mixpanel.Register("platform", "Unity");

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

## Group Analytics

```csharp theme={null}
// 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

```csharp theme={null}
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:

```csharp theme={null}
// 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

<Info>
  For manual initialization, select "Manual Initialization" in settings and call `Mixpanel.Init()`.
</Info>

## Resources

* [Full API Reference](http://mixpanel.github.io/mixpanel-unity/api-reference/annotated.html)
* [GitHub Repository](https://github.com/mixpanel/mixpanel-unity)
* [Examples](https://github.com/mixpanel/mixpanel-unity#examples)
