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

# Analytics

> Session tracking and custom events

## Session

A session starts automatically during `SusaPlaySDK.Initialize()`, which queues a `session_start`
event. There is nothing to call and no session id to track.

There is no session-end event. `OnApplicationQuit` does not fire reliably in a browser, so
session length is derived from event timestamps on the server rather than reported by the game.

## Custom events

```csharp theme={null}
SusaPlaySDK.Analytics.LogEvent("level_start");

// With parameters — pass a JSON object as a string
SusaPlaySDK.Analytics.LogEvent(
    "level_complete",
    "{\"levelId\":\"world_2_level_3\",\"attempt\":2}");
```

`LogEvent` is synchronous and queues in memory — safe to call from gameplay code.

## Flushing

Queued events are sent in batches. With the default configuration the SDK flushes on
initialization, every five minutes, and when the game is paused.

Force a send at a moment that matters — for example right after a tutorial completes:

```csharp theme={null}
await SusaPlaySDK.Analytics.Flush();
```

Flush intervals and lifecycle triggers are configurable on the `PlatformConfig` asset. The
minimum interval is 10 seconds.

Events are batched and flushed automatically. Fire-and-forget — don't await in hot paths.

## Standard events

One event is emitted automatically. Everything else is up to your game.

| Event           | When                              | SDK version |
| --------------- | --------------------------------- | ----------- |
| `session_start` | During `SusaPlaySDK.Initialize()` | 1.3.0+      |

Games built against an SDK older than 1.3.0 emit **no** events unless the game calls
`LogEvent` itself. Rebuild against 1.3.0 or later to appear in DAU, MAU, and retention.

There is no automatic `session_end`. `OnApplicationQuit` is not reliable in a browser, so an
end-of-session signal cannot be produced from Unity.

Purchase revenue is recorded server-side from the payment webhook, not by the SDK. You do not
need to log a purchase event yourself.

## Viewing data

Analytics are available in:

* Developer Portal → your game → **Analytics** (session DAU, revenue, retention)
* BigQuery — for raw event queries (contact SusaPlay to enable)

## Event naming rules

* Snake\_case only: `level_start` not `LevelStart`
* Max 40 characters
* No PII (no email, name, phone)
* Max 25 custom params per event
