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

# Session events

> Reference for the session_start and session_end events that record the start and the end of a game session, with the session length in duration_s.

The `session_start` and `session_end` events record the start and the end of a game session: one run of the game, from launch to quit, or until the player is away for 30 minutes. They are `track` events. The game reports read them: D1, D7 and D30 retention count a return with `session_start`, and **Session length** and **Playtime per DAU** read `duration_s` of `session_end`. See [game metrics](https://docs.manalens.dev/data/metrics.md#game).

Every event of a session has the same `session_id`. The SDK makes a new ID for each session.

## When they are sent

The [Godot](https://docs.manalens.dev/sdks/godot.md), [Unity](https://docs.manalens.dev/sdks/unity.md) and [Unreal](https://docs.manalens.dev/sdks/unreal.md) SDKs, and the [Web SDK](https://docs.manalens.dev/sdks/web.md#game-mode) with `game: true`, send them for you.

| Event | When |
| - | - |
| `session_start` | A new session starts: a launch (before [`game_open`](https://docs.manalens.dev/data/events/game-open)), a return after 30 minutes without focus or events, or every 24 hours in a game that stays open |
| `session_end` | The session ends: the player quits, 30 minutes pass without focus or events, or the session is 24 hours old |

* **Quit:** a desktop game delays its quit to send `session_end` and the queue, for at most 2 seconds by default. The option is `quit_timeout_s` in Godot, `QuitTimeoutSeconds` in Unity, and **Quit Timeout Seconds** in Unreal. Unsent events stay on disk for the next launch.
* **Focus:** focus loss and pause save the state and send the queue. The session stays open while the player is away for less than 30 minutes.
* **Crash:** after a crash, the next launch ends the old session and sends [`game_crash`](https://docs.manalens.dev/data/events/game-crash) in the session that crashed.
* **Web SDK in game mode:** each page load starts a new session. `session_end` is sent on `pagehide`, `reset()` or `shutdown()`, or, after 30 minutes without events or at 24 hours, with the next event.
* **Consent mode:** no session before `set_consent(true)`.
* **Server builds:** a dedicated server sends no session events unless you turn on `track_server_builds`. See [For multiplayer games](https://docs.manalens.dev/sdks/guides/multiplayer.md).
* **Other engines:** a game that sends [app events](https://docs.manalens.dev/sdks/app-events.md) over HTTP sends `session_start` and `session_end` itself, with a new `session_id` for each session.

## Properties

`session_start` has no properties.

| Property of `session_end` | Type | Description |
| - | - | - |
| `duration_s` | Number | The length of the session in seconds |
| `errors_dropped` | Number | The errors that the SDK did not send in this session because of the [error limits](https://docs.manalens.dev/data/events/error.md#limits). If errors were dropped, the field is present. |

## Sample payload

```json theme={null}
{
  "type": "track",
  "event": "session_end",
  "message_id": "c4d5e6f7-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
  "channel": "app",
  "version": "0.1.0",
  "original_timestamp": "2026-11-09T10:42:00.000Z",
  "anonymous_id": "3f0c5c1e-8a8e-4c1b-9d7e-2b1f4e6a9c10",
  "session_id": "1762682400000",
  "context": {
    "app": { "platform": "windows", "storefront": "steam", "app_version": "1.4.0", "build": "571", "engine": "unity" },
    "locale": "en-US"
  },
  "properties": { "duration_s": 2520 }
}
```

## Session ID rules

Reports count [sessions](https://docs.manalens.dev/data/metrics.md#sessions) from `session_id`, for websites and games alike. A web or app event must follow the [session ID contract](https://docs.manalens.dev/api/events.md#the-session-id-contract):

* An event with an `anonymous_id` has a `session_id`.
* The `session_id` is not the `anonymous_id`.
* An event before consent has no `anonymous_id` and no `session_id`.

The SDKs follow it for you. A website session also starts after 30 minutes without events and is at most 24 hours long. The Web SDK sends no session events outside game mode. See [core concepts](https://docs.manalens.dev/data/concepts.md#sessions).

## FAQ

> [accordion] Why do my session counts look wrong?
>
> Check that your game sends both events. A `before_send` callback that drops `session_start` or `session_end` changes your session counts: sample your own events only. A game on [app events](https://docs.manalens.dev/sdks/app-events.md) must send them itself.

> [accordion] Does a player who alt-tabs for a few minutes start a new session?
>
> No. The session stays open for 30 minutes without focus or events. After that, the next activity starts a new session.

> [accordion] Can a server event be in a game session?
>
> Yes. Send the client's `session_id` with the server event, and it is in that session. Without it, the event joins a session of the same `anonymous_id` by time. See [session ID of the client](https://docs.manalens.dev/sdks/server.md#session-id-of-the-client).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.