In the Legacy Analytics there was “Analytics.playerOptedOut” to check if the user has opted out.
Is there a similar call in the new Unity Analytics? So far I did not find one.
In the Legacy Analytics there was “Analytics.playerOptedOut” to check if the user has opted out.
Is there a similar call in the new Unity Analytics? So far I did not find one.
Yes there is,
This method calls the opt out function, an ideal use case, would be to have a button which calls the function that the user can then press if they don’t want to have any data collected on them.
You can then use a bool and save it then do a check at start up.
public void OptOut()
{
try
{
if (!consentHasBeenChecked)
{
// Show a GDPR/COPPA/other opt-out consent flow
// If a user opts out
AnalyticsService.Instance.OptOut();
}
// Record that we have checked a user's consent, so we don't repeat the flow unnecessarily.
// In a real game, use PlayerPrefs or an equivalent to persist this state between sessions
consentHasBeenChecked = true;
}
catch (ConsentCheckException e)
{
// Handle the exception by checking e.Reason
}
}
You kind out more information in the documentation here: Data privacy and consent (unity.com)
The “Analytics.playerOptedOut” was exactly that bool you describe.
Since you can re-optin by deleteing all playerPrefs, the optout state is probably stored there as well, couldn’t you just create an API call to that state?
Instead of haveing us do it our selfs
Yes, this was for Legacy Analytics.
If the player wishes to opt-back in,
Opt-BackIn#
Unfortunately there is no easy method to opt back in.
There are three options:
Hi guys, I have a similar question. Is there any option to check if all data from analytics has been removed? Let’s say that a user requested to delete all app data, including cloud saves and opted out. I would like to redirect the player to a window in which they will be prompted to press the refresh button. Then, I can check if the data from the cloud/local storage was removed and if the opt-out process was successful. While removing and checking the data is not a problem, I’m having trouble finding information on how to check if the user was successfully opted out.
Maybe if I save the user ID temporarily and check if it exists, but I haven’t found any solution for that either. Is there any way to do it in code?