Analytics
The Analytics module allows you to measure game plays and track custom gameplay events.
Plays are counted for you — initializing the SDK records one, and there is nothing to call. Custom events are for everything else you want to measure: level completions, deaths, purchases, where players stop.
Where the numbers appear
Both show up on track.y8.com under your game, roughly two hours after the event — that is how long the aggregation runs behind.
Nothing confirms delivery at the time of the call, by design, so an event you just fired showing no trace is expected rather than a fault. Give it the two hours before concluding anything is wrong.
Track Custom Event
Track a simple event:
y8Sdk.trackCustomEvent("level_complete");
Track an event with a value:
y8Sdk.trackCustomEvent("level_complete", 7);
Track multiple occurrences in a single request:
y8Sdk.trackCustomEvent("coin_collected", null, 25);
Parameters
| Parameter | Required | Description |
|---|---|---|
name |
Yes | Event name used to group events in reports. Keep names stable. |
value |
No | Measurement associated with the event. |
amount |
No | Number of occurrences represented by the request. Default: 1. |
Using Amount
Use amount instead of repeatedly sending the same event.
y8Sdk.trackCustomEvent("coin_collected", null, 25);
This records 25 occurrences in a single request.
Avoid doing this:
for (let i = 0; i < 25; i++) {
y8Sdk.trackCustomEvent("coin_collected");
}
Both represent the same number of events, but the first approach sends only one request.
Event Naming
Keep event names stable and put changing information in value.
Prefer:
y8Sdk.trackCustomEvent("track_win", 3);
instead of:
y8Sdk.trackCustomEvent("track_win_3");
This keeps your reports easier to analyze.
Important Notes
trackCustomEvent()returns nothing.- It does not return a Promise.
- Do not use
await. - The method does not throw errors.
- Analytics should not block the game loop.
- Avoid sending events every frame or game tick.
- Events are not sent when game statistics are disabled in the developer settings.
Analytics play tracking is available automatically when the SDK is initialized.
Note
Custom event tracking is not currently available in the Unity SDK.
Analytics play tracking is available automatically when the SDK is initialized.
Note
Custom event tracking is not currently available in the Construct 3 integration.
Analytics play tracking is available automatically when the SDK is initialized.
Note
Custom event tracking is not currently available in the Haxe SDK.