Search Unity

Question SDK Initialization ask dev to remove data collection ??

Discussion in 'Unity Analytics' started by Fangh, Dec 6, 2022.

  1. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    274
    Hello.

    This page : https://docs.unity.com/analytics/ComplyingWithGDPRandCCPA.html

    Explain that this code

    Code (CSharp):
    1. async void Start()
    2.    {
    3.        try
    4.        {
    5.            await UnityServices.InitializeAsync();
    6.            List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    7.        }
    8.        catch (ConsentCheckException e)
    9.        {
    10.            // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately
    11.        }
    12.    }
    is used to opt-out of data collection.

    So if I understand correclty, this code is used to "not collect analytics".
    So I should only call this piece of code if the user doesn't want their data to be collected.


    BUT

    this page : https://docs.unity.com/analytics/AnalyticsSDKGuide.html
    tells us that this code :

    Code (CSharp):
    1.  
    2. public class InitWithDefault : MonoBehaviour
    3. {
    4.     async void Start()
    5.     {
    6.         try
    7.         {
    8.             await UnityServices.InitializeAsync();
    9.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    10.         }
    11.         catch (ConsentCheckException e)
    12.         {
    13.           // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    14.         }
    15.     }
    16. }
    is the minimum amount of code required to initialize the SDK and start sending events.


    Is there an error or am I lost ?
     
  2. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    This is the bare minimum for GDPR and CCPA for automatic consent however, you need to provide an opt out method to the user.

    Here's an example of an opt out method:

    Opt-Out
    If the user wants to later opt-out they can do so using the same method for all applicable regulations by using the public void OptOut().

    bool consentHasBeenChecked;

    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
    }
    }


    I've written a little guide here how to do this in further detail: Analytics GDPR, CCPA and PIPL Consent, Opt-Out and Opt-BackIn – Unity

    I've noted your feedback and will report this to the documentation team so that we can get the documentation updated :)
     
    Laurie-Unity and Fangh like this.
  3. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    274
    Thank you.

    Another question : what should be in consentIdentfiers ?
    because mine is empty :

    Code (CSharp):
    1.  
    2.     async void Start()
    3.     {
    4.         try
    5.         {
    6.             await UnityServices.InitializeAsync();
    7.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    8.             Debug.Log($"Services initialized with ID {consentIdentifiers[0]}");
    9.         }
    10.         catch (ConsentCheckException e)
    11.         {
    12.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    13.             Debug.LogError($"User did not consent {e}", this);
    14.         }
    15.     }
    upload_2022-12-8_10-40-5.png
     
  4. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    What it is you are doing:
    • Check for any necessary consent from users which depends on their region. The CheckRequiredConsent() uses geoIP tools to determine player region based on IP and will return an empty list if the player is in an 'opt-in by default' region (GDPR, CCPA), or "pipl" if they're in a PIPL region which requires opt-in consent. The SDK will not send any events unless CheckForRequiredConsent() is called.
    • If the player is in a region where opt-in is required (i.e. PIPL) the game must display a UI asking for consent and then inform the SDK of their choice using AnalyticsService.Instance.ProvideOptInConsent()
    • The game must provide a menu options / UI / link / etc... to allow the player to opt-out. This applies both to "opt-in by default" regions, and also PIPL regions. So players who were opted in automatically should be able to opt-out ... and players who previously manually opted-in should also be able to later choose to opt-out.
    I hope this clears a few things up?
     
    Laurie-Unity likes this.
  5. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    274
    Thank you it is clearer now.
    I though consentIdentifiers[0] contained something that tells me "this person has accepted or not".
    I think your explanation should be in the documentation because it is very clear.
     
    Julian-Unity3D likes this.