Reply
Highlighted
Regular Visitor
Posts: 10
Registered: ‎10-17-2017
Accepted Solution

How to get current consent state for user?

[ Edited ]

Hello,

In "Tealium, GDPR, and Data Privacy" whitepaper (from Feb 27th), on page 18 I've read that it's possible to get consent state by using js function "getConsentState()". However, whenever I try to map that function as a UDO variable and call it in console, i get back info that it's undefined although it should be either array (in case partial category consent was provided) or a value of 1 (optin), -1 (optout) or 0 (not specified).

What am I doing wrong here?

 

Thanks

Reply
0 Kudos
Tealium Employee
Posts: 740
Registered: ‎09-01-2015

Re: How to get current consent state for user?

[ Edited ]

Hi @amarkic

The call is actually:

utag.gdpr.getConsentState()

 

You are correct that it will return "1" for Opt-In, "-1" for Opt-Out, "0" for no consent given.

Partial consent will be an array and each item will be an object.

[
{ct:1},
{ct:0},
{ct:0},
...
]

Let me know if this helps!

 

 

Regular Visitor
Posts: 10
Registered: ‎10-17-2017

Re: How to get current consent state for user?

[ Edited ]

EDIT: Never mind, found a notification from two days ago that explains everything. Thanks :)

Hi Dan,

unfortunatelly, it's not working... It seems that utag.gdpr is not defined...

con1.jpg

con2.jpg

Tealium Employee
Posts: 740
Registered: ‎09-01-2015

Re: How to get current consent state for user?

@amarkic

Apologies that it didn't work for you. Based on my quick testing, it appears the code hasn't been published. I just tried on a site that doesn't have Consent Manager enabled and saw this same error, but on a site with Consent Manager enabled it did work. Are you able to open the utag.js file in the Developer Tools Sources tab and see if utag.gdpr exist in the contents of the file? If not, then the contents aren't being published to production.

I hope this points you in the right direction, if not you'll likely need to reach out to your Account Manager for support so they can loop in an Engineering to look at the configs and your site to see the cause.

Cheers,
-Dan

Regular Visitor
Posts: 10
Registered: ‎10-17-2017

Re: How to get current consent state for user?

It's working, but it requires "Consent prompt management" to be active in "My IQ" tab...

Reply
0 Kudos
Visitor
Posts: 15
Registered: ‎11-10-2017

Re: How to get current consent state for user?

I would like to map the value of the consent state to a Google Analytics custom dimension (we are omitting GA from our consent manager scope). Can someone help with what are the steps to be able to get this value into a variable so I can map it in the GA tag?

Reply
0 Kudos
Tealium Employee
Posts: 740
Registered: ‎09-01-2015

Re: How to get current consent state for user?

@Krasner

You'll probably want to use a JS extension and leverage the following sample code.

var cs = utag.gdpr.getConsentState();
if (typeof cs != "undefined") {
if (cs == 1) utag.data.consent_state = "grant_full_consent";
else if (cs == 0) utag.data.consent_state = "no_consent_given";
else if (cs == -1) utag.data.consent_state = "decline_consent";
else if (typeof cs === "object") utag.data.consent_state = "grant_partial_consent";
}

 

Full disclosure, this is custom code and will need to be fully tested before used in a production environment.

Be sure to declare consent_state as a UDO var and then you can map it within the GA tag.

Hope this helps!
-Dan

Tealium Employee
Posts: 53
Registered: ‎08-14-2017

Re: How to get current consent state for user?

You're my hero @dan_george!. #InAwe

If you liked it then you should have put a kudo on it!
Reply
0 Kudos
Visitor
Posts: 15
Registered: ‎11-10-2017

Re: How to get current consent state for user?

[ Edited ]

Thanks @dan_george, that worked great!