Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question ConsentCheckException: Make sure GeoIP was...

Discussion in 'Unity Analytics' started by ayseaktas, Nov 6, 2022.

  1. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    Hi! I implemented UGS Analytics a month ago. But today I had a chance to try it, sending custom events. I set it up as in the documentation and it looks like I sent newPlayer event 2 times today. But on startup I get this error in the editor;
    ConsentCheckException: The required consent flow cannot be determined. Make sure GeoIP was successfully called.
    Is there something wrong with my code?
    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.Services.Core;
    3. using Unity.Services.Analytics;
    4. using System.Collections.Generic;
    5.  
    6. public class AnalyticsSetup : MonoBehaviour
    7. {
    8.     string consentIdentifier;
    9.     bool isOptInConsentRequired;
    10.  
    11.     // Start is called before the first frame update
    12.     async void Start()
    13.     {
    14.         try
    15.         {
    16.             await UnityServices.InitializeAsync();
    17.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    18.             if (consentIdentifiers.Count > 0)
    19.             {
    20.                 consentIdentifier = consentIdentifiers[0];
    21.                 isOptInConsentRequired = consentIdentifier == "pipl";
    22.             }
    23.             if (isOptInConsentRequired)
    24.             {
    25.                 AnalyticsService.Instance.ProvideOptInConsent(consentIdentifier, false);
    26.             }
    27.         }
    28.         catch (ConsentCheckException e)
    29.         {
    30.             Debug.Log(e.Reason.ToString());
    31.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately
    32.         }
    33.     }
    34. }
    And this is how I sent custom event. This code runs after the initialize;
    Code (CSharp):
    1. Dictionary<string, object> parameters = new Dictionary<string, object>()
    2.         {
    3.             { "Level", currenLevel }
    4.         };
    5.         AnalyticsService.Instance.CustomData("levelStarted", parameters);
    6.         AnalyticsService.Instance.Flush();
     
    Last edited: Nov 6, 2022
  2. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    Although I still get this error, I can see the custom events in the data explorer. For now, 33 levelStarted events have been submitted.
     
  3. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    103
    Hey @ayseaktas

    Can you confirm what what analytics version you're using.
     
  4. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    Analytics version: 4.0.1
    Unity Version: 2019.4.40f1
     
  5. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    103
    Can you try updating your Analytics package to 4.2.0

    The package name is: com.unity.services.analytics


    You should see an update for Analytics here.

    If you don't see the option to update, you can manually adjust the manifest file and amend the version number for com.unity.services.analytics to 4.2.0
     
  6. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    Okay I updated to 4.2.0 but still get this error. I closed and reopened Unity but still the same.
    Error is exactly like this;
    Code (CSharp):
    1. ConsentCheckException: The required consent flow cannot be determined. Make sure GeoIP was successfully called.
    2. Unity.Services.Analytics.Internal.ConsentTracker.ValidateConsentWasChecked () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/Runtime/Consent/ConsentTracker.cs:377)
    3. Unity.Services.Analytics.Internal.ConsentTracker.IsOptingOutInProgress () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/Runtime/Consent/ConsentTracker.cs:233)
    4. Unity.Services.Analytics.AnalyticsServiceInstance.Flush () (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/AnalyticsServiceInstance.cs:104)
    5. GameManagement.Start () (at Assets/Scripts/Managers/GameManagement.cs:53)
    6.  
    In Game Management Start() function I sent custom event(You can see in the question) and in the line 53 there is Flush() function.
     
  7. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    103
    Are you getting this error or similar when you are testing on a mobile device?
     
  8. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    No, I tested with logcat. I don't get this error on mobile(android).
    Edit: I tested with no internet connection and I got the same error on mobile too. But with internet connection there is no error.
     
    Last edited: Nov 7, 2022
  9. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    103
    Okay, it seems to being working as expected, can you make sure you are following the documentation: PIPL compliance (unity.com)

    Specifically, this bit.
    Code (CSharp):
    1. public void CheckUserConsent()
    2.    {
    3.        try
    4.        {
    5.            if (isOptInConsentRequired)
    6.            {
    7.                // Show a PIPL consent flow
    8.                // ...
    9.  
    10.                // If consent is provided for both use and export
    11.                AnalyticsService.Instance.ProvideOptInConsent(consentIdentifier, true);
    12.  
    13.                // If consent is not provided
    14.                AnalyticsService.Instance.ProvideOptInConsent(consentIdentifier, false);
    15.            }
    16.        }
    17.        catch (ConsentCheckException e)
    18.        {
    19.            // Handle the exception by checking e.Reason
    20.        }
    21.    }
    22. }
     
  10. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    35
    Yes I went through that document. And as you can see in my code I check
    if(isOptInConsentRequired)
    . If its true then this line runs:
     AnalyticsService.Instance.ProvideOptInConsent(consentIdentifier, false);

    There are two points in the document that I do not understand;
    • Where and when should I call the Check User Consent() function?
    • And how do I show the PIPL consent flow?
    Also, can I completely exclude China from Analytics without having to check?
     
  11. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    103
    You should provide the user with prompts on the screen informing them that analytics is being used and data is going to be collected with an option for yes or no buttons.

    If you don't want to publish your app in china then you don't need to use PIPL.
    However, you will need to check if you need to use GDPR or CCPA in the region you are releasing your app.


    This support article I wrote might help clear a few things up, please let me know if it does.
    Analytics GDPR, CCPA and PIPL Consent, Opt-Out and Opt-BackIn – Unity
     
  12. manuelgoellnitz

    manuelgoellnitz

    Joined:
    Feb 15, 2017
    Posts:
    316
    So according to the article CheckForRequiredConsents() returns PIPL when the user is in china, for GDPR and CCPA it will auto-opt-in so the function will never return those, since the code documentation states:
    "If the required consent was already given, an empty list is returned.
    If the user already opted out from the current legislation, an empty list is returned."

    That seems wrong to me. I am pretty sure that in europe you need to consent to analytics, at least in Germany!

    Then I read:
    "Unfortunately we don't yet have an easy method to opt back in.
    Three ways you can go about it are:

    1. Delete PlayerPrefs and restart application.
    2. Clear all data and cache for application.
    3. Uninstall application and reinstall."
    So you basically don't have a Opt-In mechanism at all at the moment.

    That's very poor in my opinion.
    Since Data privacy in our days is a really important topic.