Record an event
Record and send events from your game to Analytics to track player behavior and game activity.
読み終わるまでの所要時間 2 分最終更新 8ヶ月前
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 class and passing it into the method as in this example:
EventAnalyticsService.Instance.RecordEvent(...)MyEvent myEvent = new MyEvent{ FabulousString = "hello there", SparklingInt = 1337, SpectacularFloat = 0.451f, PeculiarBool = true};AnalyticsService.Instance.RecordEvent(myEvent);
You can also record a custom event that has no parameters by using its name alone:
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 as , , , and , so you don't need to worry about these.
userIDsessionIDeventTimestampeventUUIDplatformThe SDK also automatically records a number of standard events for you.
Unity 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. |
To learn about the standard event classes, including ones that you must record manually, refer to the list of standard events page.
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. |
For more information about the standard event classes, including ones that you must record manually, see the list of standard events page.