Get started with Analytics
Follow this workflow to install the Analytics SDK, configure data collection, and begin tracking player behavior.
Read time 3 minutesLast updated a month ago
To start using Analytics, perform the following actions:
- Meet all the prerequisites.
- Install the Analytics package.
- Manually start the Analytics SDK to begin collecting data.
- Set up Analytics.
Prerequisites
Before you begin, make sure you meet the following requirements:- You've completed the steps outlined in Get started with UGS.
- You're using a project with Unity 2021.3 or above.
Install the Analytics package
To begin using the Analytics SDK, install the Analytics package:- In the Unity Editor, navigate to Window > Package Manager.
- Select Unity Registry.
- Search for Analytics (or com.unity.services.analytics).
- Select the package, then select Install.
Manually start the Analytics SDK to begin collecting data
The process for enabling the Analytics SDK to collect data differs depending on which version of Unity and the Analytics SDK you use. To find the setup steps for the versions you use, refer to their respective section:- Unity 6.2 and later with Analytics SDK 6.1 and later
- Unity 6.1 and earlier, or Analytics SDK 6.0 and earlier
Unity 6.2 and later with Analytics SDK 6.1 and later
To enable the Analytics SDK to collect data in Unity 6.2 and later with Analytics SDK 6.1 and later, do the following:- Call the function at the start of your game to initialize the Analytics SDK and any other UGS SDKs that you use.
UnityServices.InitializeAsync() - After you confirm that you have player consent, use the Developer Data framework method to set
EndUserConsent.SetConsentState(...)toAnalyticsIntent.Granted
For the Analytics SDK to collect data, you must first confirm user consent for Analytics. In Unity 6.2 and later, the Developer Data framework controls Analytics SDK data collection according to the player consent status:using UnityEngine.UnityConsent;EndUserConsent.SetConsentState(new ConsentState { AnalyticsIntent = ConsentStatus.Granted, AdsIntent = ConsentStatus.Denied});
- If consent is granted after initialization, the SDK begins collecting data immediately.
- If consent was granted in a previous session, the SDK begins collecting data during Unity Services initialization.
- If consent is denied at any time, the SDK ceases collecting data.
EndUserConsent.SetConsentState(...)AnalyticsService.Instance.RequestDataDeletion()Unity 6.1 and earlier, or Analytics SDK 6.0 and earlier
To enable the Analytics SDK to collect data in Unity 6.1 and earlier, or using Analytics SDK 6.0 and earlier, do the following:- Call the function at the start of your game to initialize the Analytics SDK and any other UGS SDKs that you are using.
UnityServices.InitializeAsync() - After you confirm that you have player consent, call to enable data collection.
AnalyticsService.Instance.StartDataCollection()
Change player consent status
You can change a player's consent status using the following methods:- To opt a player out of data collection, call the method.
StopDataCollection() - To delete player data, call the method.
RequestDataDeletion() - To opt a player in for data collection (again), call the method.
StartDataCollection()
Set up Analytics
To set up and manage Analytics from the Unity Dashboard, do the following:- In the Unity Dashboard, select the Products tab from the sidebar.
- Under Gaming Services, go to Analytics and select Launch.