Search Unity

Question Analytics (New) - Disable Analytics for Non-GDPR\CCPA Regions

Discussion in 'Unity Analytics' started by PeachyPixels, Apr 5, 2022.

  1. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hello!

    I'm just wondering what the correct workflow is for disabling analytics in Non-GDPR/CCPA regions (PIPL excluded)

    At present it seems there are only two options...

    1) Never initialise Unity Analytics in the first place
    2) Use ProvideOptInConsent with a spoofed region (i.e. GDPR) for Non-GDPR\CCPA regions

    Both options require app restarts, although I can work around this due to the fact that I've abstracted UA from the app.

    It would be nice to have a consistent approach to opting out, so has using ProvideOptInConsent with Non-GDPR/CCPA regions ever been considered?

    Something like...

    Code (CSharp):
    1. Events.ProvideOptInConsent("other", false);
    Any advice would be much appreciated.
     
  2. EllieF_Unity

    EllieF_Unity

    Unity Technologies

    Joined:
    Nov 27, 2020
    Posts:
    39
    Hi David,

    Thanks for the feedback.

    Currently, if you are looking for player confirmation before collecting analytics, the best workflow that I can recommend is delaying the Unity Services initialization until the user opts-in, however, that does mean if you are using any other of the UGS products their initialization will also be delayed.

    If you wish to allow players to opt-out of analytics, you can also use:
    Events.OptOut()


    This will stop the Analytics SDK from being able to send events to the analytics platform and will remove all of the events that the SDK has sent in for that player in the past. Please note, it can take up to 13 days for events to be removed from your data after using this function. As this function can only be called after Analytics has started up and sent in its initial events, it cannot be used as an opt in.

    The developers have been working on a solution to allow you to disable and enable the Analytics SDK while waiting for an opt-in consent confirmation separately from the rest of the Unity Gaming Services, so a similar approach to the one you have described has been considered. I will be sure to keep you updated I receive any new information about the release of this solution.
     
  3. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Thanks for the feedback @EllieF_Unity

    Great to hear that a more flexible solution is in the works. It will definitely make for an improved experience.

    In the meantime, in there any reason why we can't use GDPR as fallback\default?

    Something like this...

    Code (CSharp):
    1. if (identifier == "gdpr")
    2.   Events.ProvideOptInConsent("gdpr", false);
    3. else
    4. if (identifier == "ccpa")
    5.   Events.ProvideOptInConsent("ccpa", false);
    6. else
    7.   Events.ProvideOptInConsent("gdpr", false);
    Would that still result in Non-GDPR\CCPA users opting out of analytics?
     
  4. EllieF_Unity

    EllieF_Unity

    Unity Technologies

    Joined:
    Nov 27, 2020
    Posts:
    39
    Since GDPR and CCPA actually only require users to be able to opt-out and erase their data at a later point instead of explicit permission before any analytics are recorded and sent to a server,
    using Events.ProvideOptInConsent("gdpr", false);
    and
    using Events.ProvideOptInConsent("ccpa", false);
    do not actually currently opt a player out of analytics. Only the PIPL identifier will opt a player out through
    Events.ProvideOptInConsent()
    .

    I have been speaking to the developers though and I have received some extra advice which might provide some insight on how best to implement a solution in the meantime. While events are recorded and cached on the device from the point that the Unity Services are initialized, they are not actually sent to the platform until after
    Events.CheckForRequiredConsents()
    has been called (unless the player is in a PIPL affected location, at which point it will continue to wait for permission).

    What you can possibly do, is implement a consent flow for your players before that function is called and get a general user consent regarding the recording of analytics, then you can call the function CheckForRequiredConsents() and provide a second part to your consent flow if extra consents are required by the specific legislations. Events are not immediately sent after
    CheckForRequiredConsents()
    , so there is a little gap of time that you may be able to add a call to the OptOut function (if the user has denied the general consent) before any of the initial events, such as gameStarted and newPlayer, are sent to the platform. As much of the code run asynchronously, however, I cannot guarantee that this workaround would work 100% of the time. However, if any of the events do slip through a forget event will be sent to the platform and that user data would be fully erased within 2 weeks.

    It is also possible to use
    Events.ProvideOptInConsent("pipl", false);
    outside of PIPL affected areas and it will still result in refusing to opt-in to analytics, however as the user is not in a PIPL affected area, it will have the same affect as using OptOut() right after checking for consents in this case.

    I hope this helps while you wait for the solution to be released.
     
    PeachyPixels likes this.
  5. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi @EllieF_Unity

    Apologies for taking so long to reply. I moved onto something else, but back on Analytics tidying up a few loose ends.

    I ran some experiments (with Charles Proxy running) and Events.ProvideOptInConsent("gdpr", false) does actually appear to stop analytic events being dispatched (without restarting the game)

    If Events.ProvideOptInConsent("gdpr", true) is then called, analytics events are dispatched once again (but this does require a game restart)

    So for GDPR/CCPA...

    [Opt-In / Default]
    >> Events Dispatched
    [Opt-Out]
    >> ForgetMe Event Dispatched
    >> No Events Dispatched
    [Opt-In]
    >> No Events Dispatched
    [Restarted Game]
    >> Events Dispatched

    On-top of that, it seems you're able to spoof consent. Even though CheckForRequiredConsents() was returning an empty list, calling Events.ProvideOptInConsent("gdpr", false) stopped events being dispatched.
     
    Last edited: Apr 15, 2022
    EllieF_Unity likes this.
  6. EllieF_Unity

    EllieF_Unity

    Unity Technologies

    Joined:
    Nov 27, 2020
    Posts:
    39
    Hi David,

    Sorry for the late reply on my side. I'm glad the initial workaround I proposed performed as expected. The results of your experiment are interesting too.

    I actually have an update on the status of all this. A new version of the Analytics SDK was released today (version 4.0.0-pre2), this version has a new function
    AnalyticsService.Instance.SetAnalyticsEnabled();
    which takes a boolean value. This function will stop and start the analytics SDK as required. You can call this function before the Unity Services are started so that no events are recorded until the consents you wish to receive are given.

    Note, as the SDK is disabled while the flag set by this function is set to true, you cannot call
     CheckForRequiredConsents()
    and
    OptOut()
    until you re-enable the SDK. Of course, if you wish to use this flag between sessions when a player has not provided consent from the very beginning, I would recommend you record their consent results in the Player Preferences. The developers are looking into making it possible to use
    OptOut()
    while the SDK is disabled so that you can unify all of the consent results without having to record it yourself.
     
    PeachyPixels likes this.
  7. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi Ellie,

    Thanks for the update.

    I spotted the new version this morning and have updated and posted some observations already...

    https://forum.unity.com/threads/unity-analytics-new-4-0-0-feedback.1273133/

    I will get around to implementing SetAnalyticsEnabled() in the coming days.

    In my game, there is an Analytics toggle (on\off) on a privacy dashboard and the current logic is something like...

    Initialise Unity Analytics
    >
    Determine Privacy Schemes
    >
    If (Privacy Scheme not reported)
    --Use Last Known or Default (GDPR)
    >
    ProvideOptInConsent(Privacy Scheme, Analytics Toggle Setting)

    I suspect instead of using the last known or default privacy scheme (if none are returned) I'll just call SetAnalyticsEnabled()

    In locales where opt out is required by law, existing data will be purged with a forget me event. I'm not sure if new SetAnalyticsEnabled() also does this, but one to check for sure. I suspect not though.

    If it doesn't (as it does when opting out) this could be a small issue for those who have privacy dashboards that are usually only available after analytics init (hopefully that makes sense!)

    I'll report back my findings once the above changes are in place.
     
    Last edited: Apr 29, 2022
  8. EllieF_Unity

    EllieF_Unity

    Unity Technologies

    Joined:
    Nov 27, 2020
    Posts:
    39
    Hi David,

    Just to add, one of the developers has proposed this flow for checking consents:
    1. Disable the SDK on application start up
    2. Check for a user’s consent
    3. If consent is provided, enable the SDK and call "CheckForRequiredConsents"
    4. If CheckForRequiredConsents returns PIPL, you can add an extra consent check to see if players are willing for their data to leave China and be stored in our Data Stores in Europe
    5. If consent is not provided, enable the SDK and call "CheckForRequiredConsents", then immediately call OptOut to permanently disable the SDK in Player Prefs
    As the SDK is disabled on start up, there will be no events recorded at the beginning at all, which means that if the player does not consent only a forget me event will be sent and it is quite certain that no other events will pass through to the Analytics platform. Naturally, the forgetMe event is still necessary as a protective measure just in case some events do somehow slip through.
     
    PeachyPixels likes this.
  9. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi Ellie,

    Thanks for the feedback again (please pass that onto the developer as well)

    So on Wednesday I added SetAnalyticsEnabled() support and have been testing yesterday and this morning. In the process I removed the fallback to last known or GDPR scheme logic. Whilst it worked, it never felt the correct solution.

    So I've ended up with something like this...

    Initialise Analytics
    >
    Determine Privacy Schemes
    >
    If (Privacy Scheme is GDPR or CCPA)
    --ProvideOptInConsent(Privacy Scheme, Analytics Toggle Setting)
    Else
    --SetAnalyticsEnabled(Analytics Toggle Setting)

    It's simpler, uses the SDK as it was meant to be used and works well with a roll your own privacy dashboard.

    I'm only supporting GDPR & CCPA (not PIPL) so in those regions opting out (from the dashboard) will dispatch a forget me event (required by the respective laws) then stop further events being dispatched.

    All other regions will disable analytics with the new approach on game init. A link to the Unity privacy policy (and ability to use the web based forget me feature) is included in the game.

    I hope that all makes sense.
     
    Last edited: Apr 29, 2022
    EllieF_Unity likes this.
  10. EllieF_Unity

    EllieF_Unity

    Unity Technologies

    Joined:
    Nov 27, 2020
    Posts:
    39
    Yup, that all makes sense and sounds like a good implementation!
     
    PeachyPixels likes this.
  11. LuftetarMan

    LuftetarMan

    Joined:
    Sep 25, 2015
    Posts:
    12
    What does it mean 1. Disable the SDKS? We should do it manuelly with code first? And as i see an code sample is really needed about these consents works. I am very confused :confused: . This posts kinda tells step by step solutions but it is not even clear well. Please help with code/project sample with UI etc.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Disabling is done with the single method SetAnalyticsEnabled. Please share the code you are currently using. I'm not entirely sure what you mean by "code first", it would required to be set in script at runtime. Otherwise if you removed the component at design time, it would be disabled for all users, probably not what you intend.
     
  13. LuftetarMan

    LuftetarMan

    Joined:
    Sep 25, 2015
    Posts:
    12
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    There is no difference, we just changed the syntax a bit, you'll want to use the former. And yes, the current recommendation is to disable the SDK as mentioned here https://forum.unity.com/threads/ana...r-non-gdpr-ccpa-regions.1263302/#post-8088389