firebase-unity-sdk icon indicating copy to clipboard operation
firebase-unity-sdk copied to clipboard

[Question] Where is documentation on how to link Google UMP consent results with Firebase consent?

Open batteredhedgehog opened this issue 4 months ago • 15 comments

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2022.3.15f1
  • Firebase Unity SDK version: 11.7.0
  • Source you installed the SDK: FirebaseAnalytics (.unitypackage or Unity Package Manager)
  • Problematic Firebase Component: consent (Auth, Database, etc.)
  • Other Firebase Components in use: none (Auth, Database, etc.)
  • Additional SDKs you are using: Admob (Facebook, AdMob, etc.)
  • Platform you are using the Unity editor on: Linux (Mac, Windows, or Linux)
  • Platform you are targeting: Android / iOS (iOS, Android, and/or desktop)
  • Scripting Runtime: IL2CPP (Mono, and/or IL2CPP)
  • Pre-built SDK from the website or open-source from this repo: _____

[REQUIRED] Please describe the question here:

I am unable to find documentation on how to configure Firebase to update consent with data coming from google's UMP. Please can you explain how to link the two, or point me to some documentation.

batteredhedgehog avatar Feb 20 '24 20:02 batteredhedgehog

Hi @batteredhedgehog,

You can use the SetConsent function to set the consent state. You may have to do some preliminary steps to set up consent mode for your app (depending on your platform). You may refer to this example in our quickstart to see how it's being used.

That said, I'll be closing this for now. Let me know if an issue arises so this ticket could be reopened.

paulinon avatar Feb 21 '24 19:02 paulinon

I think @batteredhedgehog wants some kind of conversion function from TCFStrings (which are created after UMP popup choices were made) to Firebase flags for SetConsent function.

I am interested in this too, my current guess is to rely on Tag Behaviour docs. It is possible to take selected purposes string from shared preferences (Android) or NSUserDefaults (iOS) by IABTCF_PurposeConsents key and go on from there.

But I am not sure if that is the right way to get values for SetConsent call, wonder if there are any other opinions.

Remstam avatar Feb 21 '24 19:02 Remstam

@paulinon - thanks for the info. I do understand how the SetConsent function is intended to work. As @Remstam says, I'm looking for the correct way to extract consent information from TCF strings.

  1. Can you point me to a mapping between purposes and the consent mode v2 flags used in SetConsent ?
  2. Should we be using PurposeConsents?
  3. Do we need to look into google vendor consent purposes?
  4. (edit) I notice that the TCF vendor list only has one entry for google: "755: Google Advertising Products". Does this vendor also cover Firebase Analytics ?

Any assistance would be very helpful. Answers to the above questions would greatly help me to move forward.

batteredhedgehog avatar Feb 21 '24 19:02 batteredhedgehog

Bump

cometa93 avatar Mar 03 '24 00:03 cometa93

Any updates?

OldSlash avatar Mar 07 '24 08:03 OldSlash

up

llfabris avatar Mar 13 '24 12:03 llfabris

For anyone interested - I did the following:

  • Delay initializing analytics and crashlytics until after UMP consent negotiation in my ApplicationManifest.xml using:
    <meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />
    <meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />
    <meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />
    <meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />
    <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />
  • Once consent is negotiated I determine if google (IAB vendor 755) has been granted consent for purposes 1,3,4, and either consent of legitimate intereste for purpose 7.
  • I enable crashlytics (using Crashlytics.IsCrashlyticsCollectionEnabled = true if either consent wasn't required (as determined by UMP) or if the consents in the previous step were given.
  • I enable analytics using FirebaseAnalytics.SetConsent(...) if either consent wasn't required - or using the rules described here based on the determined purpose consent status.

I dont really know if this is 100% correct - but its a start .
Any guidance from google would be greatly appreciated.

batteredhedgehog avatar Mar 26 '24 05:03 batteredhedgehog

And here is some c# code snippets I wrote to help extract consent from the TCF string.

    private const string IABTCF_PurposeConsents = "IABTCF_PurposeConsents";
    private const string IABTCF_PurposeLegitimateInterests = "IABTCF_PurposeLegitimateInterests";
    private const string IABTCF_VendorConsents = "IABTCF_VendorConsents";
    private const string IABTCF_VendorLegitimateInterests = "IABTCF_VendorLegitimateInterests";
    private const string IABTCF_PublisherConsent = "IABTCF_PublisherConsent";
    private const string IABTCF_PublisherLegitimateInterests = "IABTCF_PublisherLegitimateInterests";

    public const int IABTCF_GOOGLE_VENDOR_ID = 755;

    private static bool IsBitSet(int nonZeroBasedBitIndex, string bitString)
    {
        return nonZeroBasedBitIndex > 0 && bitString != null && bitString.Length >= nonZeroBasedBitIndex && bitString[nonZeroBasedBitIndex - 1] == '1';
    }

    public static bool HasConsent(string purposeString, string vendorString, int purposeId, int? vendorId = null)
    {
        return IsBitSet(purposeId, ApplicationPreferences.GetString(purposeString)) && ((!vendorId.HasValue) || IsBitSet(vendorId.Value, ApplicationPreferences.GetString(vendorString)));
    }

    public static bool HasPurposeConsent(int purposeId, int? vendorId = null)
    {
        return HasConsent(IABTCF_PurposeConsents, IABTCF_VendorConsents, purposeId, vendorId);
    }

    public static bool HasLegitimateInterest(int purposeId, int? vendorId = null)
    {
        return HasConsent(IABTCF_PurposeLegitimateInterests, IABTCF_VendorLegitimateInterests, purposeId, vendorId);
    }

    public static bool HasPublisherConsent(int purposeId)
    {
        return HasConsent(IABTCF_PublisherConsent, null, purposeId);
    }

    public static bool HasPublisherLegitimateInterest(int purposeId)
    {
        return HasConsent(IABTCF_PublisherLegitimateInterests, null, purposeId);
    }

batteredhedgehog avatar Mar 26 '24 05:03 batteredhedgehog

Hi,

It seems that since Firebase Android SDK 32.8.0 and Firebase iOS SDK 10.23.0, Firebase Analytics gets a new feature:

Any ETA on when this will be available in the Unity SDK ? Or maybe is it possible to just update the dependencies ?

binouze avatar Apr 15 '24 12:04 binouze

Ok, 11.9.0 release gets updates to Android 32.8.1 and iOS 10.24.0 respectively. Does this mean it is no more necessary to manually call SetConsent as Analytics will now itself automatically get the values from TCF string internally?

Remstam avatar Apr 18 '24 21:04 Remstam

Bump

akshaymoonfrog avatar Apr 19 '24 11:04 akshaymoonfrog

Hi,

With the 11.9.0 update is it still necessary to modify the AndroidManifest.xml to add:

<meta-data android:name="google_analytics_default_allow_analytics_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_storage" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_user_data" android:value="false" />
<meta-data android:name="google_analytics_default_allow_ad_personalization_signals" android:value="false" />
<meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

Or all this is done automatically based on the TCF values ?

How does this work for non UE users ? Will it reactivate it automatically or I need to do it manually ?

What about the values changes, if I show the GoogleUserMessagingPlatform form to the user, is there something to call on FirebaseAnalytics to update the values when the form is closed ?

binouze avatar Apr 23 '24 13:04 binouze

Any updates?

ismetdegoo avatar May 02 '24 11:05 ismetdegoo