---
url: https://simpledatalogs.com/docs/quickstarts/unity.md
description: >-
  Add simpledatalogs to a Unity game with the Unity package, with launches,
  sessions, scene views and errors captured by one argument.
---

# Unity

## Install

In **Window → Package Manager**, click **+**, choose **Add package from git URL…** and enter:

```text
https://github.com/XKD-Labs/simpledatalogs-unity.git
```

## Add it

```csharp
using System.Collections.Generic;
using UnityEngine;
using XKDLabs.SimpleDataLogs;

public sealed class Analytics : MonoBehaviour
{
    // Once, at launch, on the main thread.
    private void Awake()
    {
        SimpleDataLogs.Configure("sdl_pub_…", autocapture: AutocaptureOptions.All);
    }
}
```

```csharp
// Anywhere:
SimpleDataLogs.Track("level_complete", new Dictionary<string, object> { ["level"] = 3, ["score"] = 1200 });
```

Use a public `sdl_pub_` key. Events wait in a crash-safe outbox until a `202`, so nothing is lost if the game is killed.

## Send everything, or only what you choose

* **Everything:** `AutocaptureOptions.All` sends launches, sessions, scene views and errors.
* **Pick:** `AutocaptureOptions.Sessions | AutocaptureOptions.SceneViews`.
* **Only your own events:** leave `autocapture` out.

Screens that are not scenes, such as a shop panel:

```csharp
SimpleDataLogs.TrackScreen("Shop");
```

## In the first minute

* `session_start` and `app_launched` (with `is_first_launch`) within 10 seconds (5 in the Editor and development builds), or at once with `SimpleDataLogs.Flush()`.
* A `screen_view` each time a scene loads.
* Pausing the game or switching away also sends what is waiting.

## Autocapture defaults

| Option | With `AutocaptureOptions.All` |
|---|---|
| `AppLaunches` | on |
| `Sessions` (30 minutes away ends one) | on |
| `SceneViews` (`screen` = the scene name) | on |
| `Errors` (logged exceptions and errors, as `app_error`) | on |

Everything else, including the opt-out and WebGL notes, is in the [Unity SDK](/sdks/unity) reference.
