# Get started with Analytics

> Follow this workflow to install the Analytics SDK, configure data collection, and begin tracking player behavior.

To start using Analytics, perform the following actions:

* [Meet all the prerequisites](#prerequisites).
* [Install the Analytics package](#install-the-analytics-package).
* [Manually start the Analytics SDK to begin collecting data](#manually-start-the-analytics-sdk-to-begin-collecting-data).
* [Set up Analytics](#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](/services/getting-started.md).
* You're using a project with Unity 2021.3 or above.

> **Note:**
>
> Analytics is compatible with the following operating systems and platforms: iOS, Android, Windows, macOS, and WebGL.

## Install the Analytics package

To begin using the Analytics SDK, install the Analytics package:

1. In the Unity Editor, navigate to **Window** > **Package Manager**.
2. Select Unity Registry.
3. Search for Analytics (or com.unity.services.analytics).
4. 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.2-and-later-with-analytics-sdk-6.1-and-later)
* [Unity 6.1 and earlier, or Analytics SDK 6.0 and earlier](#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:

1. Call the `UnityServices.InitializeAsync()` function at the start of your game to initialize the Analytics SDK and any other UGS SDKs that you use.
2. After you confirm that you have player consent, use the Developer Data framework `EndUserConsent.SetConsentState(...)` method to set `AnalyticsIntent` to `Granted`.

The following code block provides an example implementation:

```cs
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](/cloud/developer-data.md) 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 `EndUserConsent.SetConsentState(...)` and then call the `AnalyticsService.Instance.RequestDataDeletion()` method. If you request data deletion while consent is still granted, the SDK throws an exception and does not make the request.

For more information about managing privacy and obtaining player consent for data collection with the Developer Data framework, refer to [User consent](/cloud/developer-data/user-consent.md).

### 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:

1. Call the `UnityServices.InitializeAsync()` function at the start of your game to initialize the Analytics SDK and any other UGS SDKs that you are using.
2. After you confirm that you have player consent, call `AnalyticsService.Instance.StartDataCollection()` to enable data collection.

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](../privacy-and-consent/manage-data-privacy).

### 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 `StopDataCollection()` method.
* To delete player data, call the `RequestDataDeletion()` method.
* To opt a player in for data collection (again), call the `StartDataCollection()` method.

> **Important:**
>
> You must call `StartDataCollection()` at the start of each session to enable data collection. The SDK doesn’t track player consent status between sessions.

## Set up Analytics

To set up and manage Analytics from the Unity Dashboard, do the following:

1. In the [Unity Dashboard](https://cloud.unity.com), go to **Development** > **Products**.
2. 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.

> **Note:**
>
> Only [Organization Owners](/cloud/organizations/roles-and-permissions.md) can sign up for Analytics.

## 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](https://cloud.unity.com/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](../events/standard-events).

To learn how to build and record your own events, refer to the following tutorials:

* [Create a custom event](../events/custom-event)
* [Record an event](../events/record-event)

> **Note:**
>
> To learn about how the SDK works, refer to [SDK behavior](../sdks-and-apis/sdk-behaviour).
