Class Events
Namespace: Unity.Services.Analytics
Syntax
public static class Events : object
Fields
PrivacyUrl
This is the URL for the Unity Analytics privacy policy. This policy page should be presented to the user in a platform-appropriate way along with the ability to opt out of data collection.
Declaration
public static readonly string PrivacyUrl
Field Value
| Type | Description |
|---|---|
| String |
Properties
Buffer
Declaration
public static IBuffer Buffer { get; }
Property Value
| Type | Description |
|---|---|
| IBuffer |
Methods
AdImpression(Events.AdImpressionArgs)
Record an Ad Impression event.
Declaration
public static void AdImpression(Events.AdImpressionArgs args)
Parameters
| Type | Name | Description |
|---|---|---|
| Events.AdImpressionArgs | args | (Required) Helper object to handle arguments. |
CheckForRequiredConsents()
Returns identifiers of required consents we need to gather from the user
in order to be allowed to sent analytics events.
This method must be called every time the game starts - without checking the geolocation,
no event will be sent (even if the consent was already given).
If the required consent was already given, an empty list is returned.
If the user already opted out from the current legislation, an empty list is returned.
It involves the GeoIP call.
ConsentCheckException is thrown if the GeoIP call was unsuccessful.
Declaration
public static async Task<List<string>> CheckForRequiredConsents()
Returns
| Type | Description |
|---|---|
| Task<List<String>> | A list of consent identifiers that are required for sending analytics events. |
Exceptions
| Type | Condition |
|---|---|
| ConsentCheckException | Thrown if the GeoIP call was unsuccessful. |
CustomData(String, IDictionary<String, Object>)
Record a custom event. A schema for this event must exist on the dashboard or it will be ignored.
Declaration
public static void CustomData(string eventName, IDictionary<string, object> eventParams)
Parameters
| Type | Name | Description |
|---|---|---|
| String | eventName | |
| IDictionary<String, Object> | eventParams |
Flush()
Forces an immediately upload of all recorded events to the server, if there is an internet connection.
Declaration
public static void Flush()
Exceptions
| Type | Condition |
|---|---|
| ConsentCheckException | Thrown if the required consent flow cannot be determined.. |
OptOut()
Opts the user out of sending analytics from all legislations.
To deny consent for a specific opt-in legislation, like PIPL, use ProvideConsent(string key, bool consent) method)
All existing cached events and any subsequent events will be discarded immediately.
A final 'forget me' signal will be uploaded which will trigger purge of analytics data for this user from the back-end.
If this 'forget me' event cannot be uploaded immediately (e.g. due to network outage), it will be reattempted regularly
until successful upload is confirmed.
Consent status is stored in PlayerPrefs so that the opted-out status is maintained over app restart.
This action cannot be undone.
Declaration
public static void OptOut()
Exceptions
| Type | Condition |
|---|---|
| ConsentCheckException | Thrown if the required consent flow cannot be determined.. |
ProvideOptInConsent(String, Boolean)
Sets the consent status for the specified opt-in-based legislation (PIPL etc).
The required legislation identifier can be found by calling CheckForRequiredConsents method.
If this method is tried to be used for the incorrect legislation (PIPL outside China etc),
the ConsentCheckException is thrown.
Declaration
public static void ProvideOptInConsent(string identifier, bool consent)
Parameters
| Type | Name | Description |
|---|---|---|
| String | identifier | The legislation identifier for which the consent status should be changed. |
| Boolean | consent | The consent status which should be set for the specified legislation. |
Exceptions
| Type | Condition |
|---|---|
| ConsentCheckException | Thrown if the incorrect legislation was being provided or the required consent flow cannot be determined. |
Transaction(Events.TransactionParameters)
Record a Transaction event.
Declaration
public static void Transaction(Events.TransactionParameters transactionParameters)
Parameters
| Type | Name | Description |
|---|---|---|
| Events.TransactionParameters | transactionParameters | (Required) Helper object to handle parameters. |