- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
05-15-2023 06:44 AM - edited 05-16-2023 12:44 AM
Hello,
So I am setting partial consent in my Android Kotlin application, setting consentManager.userConsentCategories, but it sends two requests: first with full consent, and later with what categories I have selected:
{ //... "tealium_event": "grant_full_consent", "consent_categories": ["analytics", "affiliates", "display_ads", "search", "email", "personalization", "social", "big_data", "misc", "cookiematch", "cdp", "mobile", "engagement", "monitoring", "crm"], "policy": "gdpr", //... }
And later there is a proper one:
{ //... "tealium_event": "grant_partial_consent", "consent_categories": ["analytics"], "policy": "gdpr", //... }
Is it necessary? Can I somehow get rid of this additional call?
Here is a code snippet I'm using:
fun enableAnalytics(enable: Boolean) { Tealium[INSTANCE_KEY]?.consentManager?.run { userConsentCategories = if (enable) { setOf(ConsentCategory.ANALYTICS) } else { // userConsentStatus = ConsentStatus.NOT_CONSENTED - commented out for test purposes but it doesn't matter emptySet() } } }
I'm using
com.tealium:kotlin-core:1.5.1
05-15-2023 09:36 AM
It seems that your application is first sending a "grant_full_consent" event before it sends the "grant_partial_consent" event with the categories you have selected. This behavior is not ideal, as it may lead to unnecessary data processing or incorrect consent management.
To resolve this issue, make sure you are only setting the consent categories that the user has agreed to, and avoid granting full consent beforehand. Here's how you can update consent preferences for partial consent with Tealium Consent Manager:
Kotlin
import com.tealium.consentmanager.ConsentManager
import com.tealium.consentmanager.UserConsentPreferences
import com.tealium.consentmanager.UserConsentStatus
// Get the instance of the Consent Manager
val consentManager = ConsentManager.getInstance(tealium)
// Define the list of consent categories that the user has agreed to
val userConsentCategories = listOf("analytics")
// Set the user consent status and categories
val userConsentPreferences = UserConsentPreferences(
UserConsentStatus.CONSENTED,
userConsentCategories
)
// Update the consent preferences in the Consent Manager
consentManager.userConsentPreferences = userConsentPreferences
By following this approach, you should be able to avoid the "grant_full_consent" event, and only send the "grant_partial_consent" event with the consent categories that the user has agreed to. Make sure that you are not calling any method that grants full consent before setting the user's partial consent preferences.
05-15-2023 10:32 PM - edited 05-16-2023 12:08 AM
Thank you for your answer. Sorry, I should have shown my code as well:
fun enableAnalytics(enable: Boolean) { Tealium[INSTANCE_KEY]?.consentManager?.run { userConsentCategories = if (enable) { setOf(ConsentCategory.ANALYTICS) } else { // userConsentStatus = ConsentStatus.NOT_CONSENTED - commented out for test purposes but it doesn't matter emptySet() } } }
I cannot access userConsentPreferences for some reason it is not available in Kotlin ConsentManager:
https://docs.tealium.com/platforms/android-kotlin/api/consent-manager/
Oh, now I see that the package has been changed for ConsentManager:
import com.tealium.core.consent.*
vs yours
import com.tealium.consentmanager.ConsentManager
I'm using
com.tealium:kotlin-core:1.5.1
05-16-2023 12:44 AM
05-16-2023 04:51 AM
05-16-2023 05:02 AM - edited 05-16-2023 05:03 AM
Unfortunately not. The code snippet I have added in my posts here, was already there and it was producing those two consent requests already. And I couldn't use your code snippet since I can't access userConsentPreferences field of consentManager class. Also the imports looks a bit different than what I have (different version of Tealium library maybe? Mine is 1.5.1)
05-16-2023 06:52 AM
Let's try another approach. Instead of setting the userConsentCategories, you can try to update the consent preferences using the setUserConsentStatus() method. Here's an approach:
import com.tealium.consentmanager.UserConsentStatus
// Get the instance of the Consent Manager
val consentManager = tealium.consentManager
// Define the list of consent categories that the user has agreed to
val userConsentCategories = listOf("analytics")
// Set the user consent status and categories
consentManager.setUserConsentStatus( UserConsentStatus.CONSENTED, userConsentCategories )
Make sure you are not calling any method that grants full consent before setting the user's partial consent preferences using this approach.
05-16-2023 11:19 PM - edited 05-16-2023 11:30 PM
Unfortunately I don't even have setUserConsentStatus() method. There is only userConsentStatus attribute of ConsentManager object to be set and it accepts only ConsentStatus type. And also I don't have have UserConsentStatus class and my ConsentManager is in package com.tealium.core.consent package
05-17-2023 03:46 AM
Copyright All Rights Reserved © 2008-2023