Record an event
Record and send events from your game to Analytics to track player behavior and game activity.
Read time 2 minutesLast updated 21 hours ago
Whether you are recording a standard event provided by Unity Analytics or a custom event that you have created especially for your game, the way to send data to Analytics is the same. Events must conform to a schema that exists on the dashboard or else they are rejected as invalid. You can view your configured events, and create new custom events, in the Event Manager. To make it easy to record events that are correctly structured, the SDK provides helper classes for standard events and a base class you can extend for custom events. Events are recorded by building an instance of an
EventAnalyticsService.Instance.RecordEvent(...)You can also record a custom event that has no parameters by using its name alone:MyEvent myEvent = new MyEvent{ FabulousString = "hello there", SparklingInt = 1337, SpectacularFloat = 0.451f, PeculiarBool = true};AnalyticsService.Instance.RecordEvent(myEvent);
AnalyticsService.Instance.RecordEvent("myEvent");
Events recorded by the Analytics SDK are batched and uploaded automatically every 60 seconds.
Once your events have been uploaded, you can view them in the Event Browser.
Automatic events
The SDK automatically populates every event with common parameters, such asuserIDsessionIDeventTimestampeventUUIDplatformUnity 6.2 and later with Analytics SDK 6.1 and later
Event | Description |
|---|---|
| Recorded when consent is granted or during |
| Recorded when consent is granted or during |
| Recorded if the user ID has changed. This recording occurs either when consent is newly granted, or during |
| Recorded every 60 seconds if no other events have been recorded in that time. |
| Recorded when the game is closed. Note that if Unity is not allowed to shut down gracefully by the operating system, this may not occur, or may be cached to disk for upload at the start of the next session. |
Unity 6.1 and earlier, or Analytics SDK 6.0 and earlier
Event | Details |
|---|---|
| Recorded the first time |
| Recorded the first time |
| Recorded the first time |
| Recorded every 60 seconds if no other events have been recorded in that time. |
| Recorded when the game is closed. Note that if Unity is not allowed to shut down gracefully by the operating system, this may not occur, or may be cached to disk for upload at the start of the next session. |