China’s National People’s Congress has passed the Personal Information Protection Law (PIPL), to protect the data privacy of Chinese citizens. It is effective starting November 1st, 2021, and requires players in China to provide opt-in consent to their data being processed and opt-in consent to their data being transferred outside of China.
In order to comply with this legislation, Unity must block data collection from players in China until they provide their consent to both opt-ins. This means that from November 1st, 2021, data from players in China will cease to be processed. Analytics reporting and player engagement systems reliant on data will not be available for players in China.
The Analytics Data Privacy plugin contains relevant functionality to communicate the player’s consent for both opt-ins. As a developer, you will need to add the Data Privacy plugin to your game along with reference to the Unity Privacy Policy in order to utilize the consent flow. Once the consent flow is in place, data collection will resume for players in China who opt in.
The Unity Analytics Data Privacy plugin gives your players control over the SDK’s data collection. This plugin is part of the Unity Analytics library package. You can use the Package Manager in the Unity Editor (Window > Package Manager) to double-check that the package is enabled in a project.
The plugin does not support the following platforms:
Note: For versions of Unity prior to 2018.3, you must use the Unity Analytics Data Privacy asset package from the Unity Asset Store. The Asset Store version can be used with Unity 4.7, 5.1+, 2017.1+, 2018.1, and 2018.2.
The Data Privacy plugin includes a Unity UI button prefab, which you can place in a suitable location of your user interface. When a player clicks this button, it opens the Player Data Privacy page in a web browser where the player can opt in to the following consents:
1. Consent to collect data for analytics.
2. Consent to transfer data outside of mainland China.
Developers can also provide their own user interfaces and open the Player Data Privacy page using the data privacy API.
Important: If a player has a browser pop-up blocker enabled, their browser can prevent the data privacy page from opening. Some browsers note that a page has been blocked, but others provide no notice at all. Consider adding a message in your user interface that warns players that a pop-up blocker might prevent the page from opening.
To implement the Data Privacy plugin-provided UI button:
Packages/Analytics Library/DataPrivacy
folder) to the Canvas GameObject in your Scene.Note: The version of the button prefab under the Packages
folder is read-only. You can make changes to the instance of the button in the Scene hierarchy, but you cannot save those changes back to the original prefab.
If you use a custom interface button, you can request the URL of the user’s data opt-in page, then open that URL in a browser or web view:
Packages/Analytics Library/DataPrivacy
folder. Unity encourages you to use this icon on your data privacy prompt to provide a consistent visual cue for players encountering data privacy controls in Unity games.DataPrivacy.FetchPrivacyUrl()
method. This takes an Action<string>
object that it invokes when the network request completes. You can optionally pass in a second Action<string>
function to handle cases where the network request fails.FetchPrivacyUrl()
request, use the Application.OpenURL()
method to open the URL in a browser.例えば、次のスクリプトは任意のゲームオブジェクトのクリックに応答してプレイヤーの個人データ管理ページを開きます。
using System;
using UnityEngine;
using UnityEngine.Analytics;
public class OptOutHandler : MonoBehaviour {
static void OnFailure(string reason)
{
Debug.LogWarning(String.Format("Failed to get data privacy page URL: {0}", reason));
}
void OnURLReceived(string url)
{
Application.OpenURL(url);
}
public void OpenDataURL()
{
DataPrivacy.FetchPrivacyUrl(OnURLReceived, OnFailure);
}
void OnMouseOver(){
if(Input.GetMouseButtonUp(0)){
OpenDataURL();
}
}
}
See documentation on the Unity Analytics DataPrivacy API for more information.