Documentation

​
​

Development

User Acquisition

Monetization

Industry

Analytics

Unity SDK

Client API

Analytics

LiveOps
​
​
Analytics
  • Overview
  • Get started
  • Pricing
  • Concepts
  • Tutorials
  • Reference
    • Standard events
    • Standard audiences
    • Reserved parameter names
    • Data Explorer V1 metrics
    • Data Explorer V2 measures and metrics
    • SDK Event class
    • SDK CustomEvent class
    • SDK behavior
    • SQL Data Explorer queryable tables
    • SQL Data Explorer cookbook
    • Data Access available views
    • Glossary
  • Privacy and consent
  • FAQ
  1. Unity Analytics

The CustomEvent class

Use the generic CustomEvent class to record events without creating dedicated event classes.
Read time 1 minute
Last updated 7 months ago

For simplicity and quick turn-around, the Analytics SDK offers a generic
CustomEvent
class that you can use for any custom event in a very similar way to the plain dictionary API used in earlier SDK versions. This comes at the cost of the type safety and validation options offered by using dedicated sub-classes for each type of event, but may be useful during migration or prototyping.
CustomEvent myEvent = new CustomEvent("MyEvent"){ { "fabulousString", "woah!" }, { "peculiarBool", true }, { "sparklingInt", 1337 }, { "spectacularFloat", 313.37f }, { "timelessTimestamp", DateTime.Now }};AnalyticsService.Instance.RecordEvent(myEvent);
Warning
Although the parameter values are taken in as
object
type, values must actually be one of the following types:
string
,
int
,
long
,
float
,
double
,
bool
or
DateTime
. If you attempt to add a value of an unsupported type, the
CustomEvent
class throws an
ArgumentException
.
DateTime
support was introduced in version 6.2.0 of the SDK.

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.


    Report a problem with this page