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 3 months 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.
You can now start using the Analytics SDK.
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
The following code block provides an example implementation:
using UnityEngine.UnityConsent;EndUserConsent.SetConsentState(new ConsentState { AnalyticsIntent = ConsentStatus.Granted, AdsIntent = ConsentStatus.Denied});
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:
- 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.
To delete player data, deny consent using the and then call the method. If you request data deletion while consent is still granted, the SDK throws an exception and does not make the request.
EndUserConsent.SetConsentState(...)AnalyticsService.Instance.RequestDataDeletion()For more information about managing privacy and obtaining player consent for data collection with the Developer Data framework, refer to User consent.
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()
For the SDK to collect data, you must confirm that the user has consented to the use of Analytics. For more information about managing privacy and obtaining player consent, refer to Manage data privacy with the SDK.
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, go to Development > Products.
- Select Analytics.
When you launch Analytics for the first time, it appears in the Shortcuts section on the sidebar and opens the Game Performance page.
Next steps
After you enable data collection, the SDK begins collecting events and uploading them at a regular cadence of every 60 seconds while your game is running.
The SDK automatically records some events, enabling you to directly access Analytics in the Unity Dashboard for data analysis. For a list of which events are sent automatically and which require manual configuration, refer to Standard Events.
To learn how to build and record your own events, refer to the following tutorials: