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 1 year ago • 33 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

up

WBoda avatar May 15 '24 03:05 WBoda

Hi folks, could you kindly add a thumbs up emoji to the author's original post. This will help us keep track of issues under our radar. That said, I'll bring this up to our engineer sync to get some feedback. Thanks!

argzdev avatar May 15 '24 13:05 argzdev

up

stergios222 avatar May 26 '24 11:05 stergios222

Bump

Iq51 avatar Jun 04 '24 22:06 Iq51

Bump. Can we please get some guidance on this.

batteredhedgehog avatar Jun 17 '24 01:06 batteredhedgehog

Bump. Firebase shows a message, which reads "Ads personalization consent signals not detected".

This page describes how to enable consent mode with TCF and says it is automatically enabled: https://developers.google.com/tag-platform/security/guides/implement-TCF-strings#apps

Do we still need to manually set everything else to false in AndroidManifest.xml though?

nahrak avatar Jun 17 '24 20:06 nahrak

Hey all,

Sorry for the lost wait in a response, with something like this we wanted to make sure we had the correct response, which took a while.

I believe that UMP needs to enable automatic TCF integration by setting the IABTCF_EnableAdvertiserConsentMode bit. This is partially documented on this page, including how to do so for Android and iOS apps: https://developers.google.com/tag-platform/security/guides/implement-TCF-strings#apps By doing so, the Google Analytics SDK will be able to read TCF strings written by UMP, so you shouldn't need to call out all the additional flags, possibly just that one.

a-maurice avatar Jun 29 '24 00:06 a-maurice

Thanks for replying, but your answer is a bit vague. Can you please provide us with a real implementation example, remembering that this is a unity sdk question.

Lets say we enable the IABTCF_EnableAdvertiserConsentMode in the AndroidManifest.xml (Android) and/or info.plist (iOS) bit as per the documentation you linked.

Does this mean:

  • that in jurisdictions in which the UMP does not require consent, Firebase analytics will continue to function normally?
  • that in jurisdictions in which the UMP does require consent that NO information will be sent by the firebase analytics SDK before consent is obtained?
  • that in jurisdictions in which consent is required but not given, that we should go ahead and initialise analytics, and that analytics will respect this choice?
  • that when consent is given but subsequently withdrawn, analytics will respect this change?

batteredhedgehog avatar Jun 29 '24 01:06 batteredhedgehog

Lets say we enable the IABTCF_EnableAdvertiserConsentMode in the AndroidManifest.xml (Android) and/or info.plist (iOS) bit as per the documentation you linked.

I guess this manifest/plist setup just allows Firebase not to take TCF strings into consideration:

  • if google analytics tcf data enabled is set to true (is this default value? Probably yes), then Firebase Analytics will rely on IAB flags
  • if not enabled, then we have to use SetConsent method explicitly and dig out all the parameters for this method from IAB flags ourselves

As @a-maurice wrote IABTCF_EnableAdvertiserConsentMode bit has to be set also for everything to work out. Other CMP platforms state that they put that bit explicitly:

  • Didomi: https://developers.didomi.io/cmp/mobile-sdk/google-consent-mode#enabling-consent-modes-tcf-integration
  • OneTrust: https://my.onetrust.com/s/article/UUID-64f4f90c-38f8-bb69-e9b1-c8538dc9b774?language=en_US

Does UMP set this bit automatically? Probably no.

So the working scenario with UMP as for now looks like this:

  1. Set google analytics tcf data enabled = true in manifest/plist (maybe nothing to do here if true is default value)
  2. UMP popup is being shown, user choose some settings
  3. Set IABTCF_EnableAdvertiserConsentMode bit explicitly via SharedPreferences/NSUserDefaults
  4. Init Firebase Analytics
  5. Firebase Analyitcs reads TCF strings automatically and behaves appropriately

Remstam avatar Jul 01 '24 10:07 Remstam

the documentation at https://developers.google.com/tag-platform/security/guides/implement-TCF-strings#tcf_integration_behavior mentions the

  • ad_storage
  • ad_user_data
  • ad_personalization being mapped from TCF Purposes, but not the analytics_storage one. Do we need to set this manually ?

stergios222 avatar Jul 01 '24 18:07 stergios222

So the working scenario with UMP as for now looks like this:

  1. Set google analytics tcf data enabled = true in manifest/plist (maybe nothing to do here if true is default value)
  2. UMP popup is being shown, user choose some settings
  3. Set IABTCF_EnableAdvertiserConsentMode bit explicitly via SharedPreferences/NSUserDefaults
  4. Init Firebase Analytics
  5. Firebase Analyitcs reads TCF strings automatically and behaves appropriately

On iOS, this works to a certain degree only.

If you grant permissions and afterwards revoke them, ad_storage, ad_user_data and ad_personalization are not reset correctly, they are still set to granted. Probably because the UserDefaults.standard.string(forKey: "IABTCF_PurposeConsents") is set to "0" and doesn't include all the required purposes.

So you definitely need to reset all permissions before showing the UMP dialog (again).

weakfl avatar Jul 02 '24 07:07 weakfl

Guys,

What should be the correct flow for when I only show the UMP after the login?

In the .plist or AndroidManifest, I add them by default as granted and I need to make sure the Firebase is initialised at App start since I'd like to catch issues/crashes. I only show the UMP after the login is done and since the login comes at a later stage is it fine to have those permissions as granted and setConsent after showing the UMP post login? (with an ability to further update consent on the settings panel)??? (Tagging @batteredhedgehog since kind of had a similar situation)

(@paulinon / @a-maurice )

ananttheant avatar Jul 10 '24 17:07 ananttheant

@a-maurice By the way, if IABTCF_EnableAdvertiserConsentMode approach works and consent is transferred automatically, I would like to know what exactly the flag values are for custom analytics purposes. Could you please consider the idea of adding GetConsent method? It should return current flags state, so we will know, what's been transferred after UMP choices are made.

Remstam avatar Jul 12 '24 09:07 Remstam

@a-maurice - is there any update on how this really works? the minimal information provided and limited documentation isn't sufficient for us devs to implement firebase analytics with UMP with any confidence that we're satisfying privacy requirements.

From comments above by @weakfl - it isn't clear under which exact circumstances consent mode is reconfigured to respect TCF - which is as frustrating and vague as everything else to do with consent, firebase and admob. I think I'll trust my manual implementation until Google can provide us with definitive info.

batteredhedgehog avatar Jul 16 '24 02:07 batteredhedgehog

i also wonder how all this works together iwth opt-in option the docs explain. I would lie to initially have Firebase Disabled and then show the UMP to the user. But does that enable my firebase stuff or does this only handle Google Mobile Ad stuff. I am really confused by the amount of different documentations.

Opt-In example:

        <!-- Disable Crashalytics as default -->
        <meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="false" />

        <!-- Disable Firebase Analytics -->
        <meta-data
            android:name="firebase_analytics_collection_enabled"
            android:value="false" />

        <!-- Disable Performance Monitor -->
        <meta-data
            android:name="firebase_performance_collection_enabled"
            android:value="false" />

Then manually i would call: FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(true);

@ananttheant did you figure out what to do? I think i aim for the same setup. I kinda hate the idea to show multiple popups on first start to get the user consent. One Consent request with UMP would be nice.

ynnob avatar Jul 26 '24 22:07 ynnob

@ynnob

I used this documentation.

By default, I've set all the consents as granted, and used the eu_consent_policy set as false to initialise the Firebase normally without any change in its flow. After the login, we show the CMP popup, overriding the value for consents.

Then finally you can pass on the consent values to the respective 3rd party SDKs

ananttheant avatar Aug 06 '24 14:08 ananttheant

Hey @a-maurice - do you have any guidance on how to properly do this? Or if anyone is working on a doc?

emfigura avatar Aug 11 '24 03:08 emfigura