How to pass a cookie values as custom dimension?

Gold Contributor
Gold Contributor
In Universal Analytic, I want to pass a cookie value directly in to a custom dimension and use in reports. This cookie will get set in every hit. 1. I created a first party cookie in data layer 2. Mapped that to Universal Analytic tag 3. Created the Dimension in Analytic property I can see the cookie is getting set with values but its not getting set in to the custom dimension. Am i missing a step here? Do i need to use a set data value extension to assign the cookie value back to dimension?
5 REPLIES 5

How to pass a cookie values as custom dimension?

Employee Emeritus
Pradeep, how is the cookie getting set? are you setting it via an extension in Tealium? (If so, what is it's scope?) If the cookie is not being set by a Tealium extension then is it being set before utag.js runs?

How to pass a cookie values as custom dimension?

Gold Contributor
Gold Contributor
Hi Clint, Thanks for you quick response. I'm using a JS code extension (set to DOM Ready scope) to set the cookie using following code (to expire in one year). utag.loader.SC("utag_main", {"visitor_cookie": utag_data['visitor_id']}); Cheers, Pradeep

How to pass a cookie values as custom dimension?

Employee Emeritus

Ok, I think I see what's going on here but let me ask a question first. If the visitor_id value is already part of utag_data (as shown in your function) then why is it necessary to set it in a cookie before passing it to GUA? You ought to be able to map visitor_id directly to your GUA custom dimension without setting a cookie first. That being said, in your function above the cookie namespace is set to utag_main but I think you may have defined a data source of visitor_id (type cookie value) and mapped visitor_id to the desired location in GUA. If that's the case then you are mapping a data source that has no defined value to GUA so even though it looks like an error it's actually working correctly. If the above is indeed the case, then you need to make sure the data source being mapped is utag_main_visitor_id because visitor_id is being stored as a parameter in the utag_main cookie. However, if your data source IS utag_main_visitor_id already then it's possible that the cookie is getting set AFTER mapping for GUA runs and therefore the value of the data source is not set. Reference: https://community.tealiumiq.com/t5/Tealium-iQ-Tag-Management/Tealium-Cookies/ta-p/138

How to pass a cookie values as custom dimension?

Gold Contributor
Gold Contributor
Hi Clint, Thank you for your comment. You are spot on, i updated the cookie name and mapped it to 'utag_main_cookie_name' and it worked. We already have the visitor ID mapped to GUA directly for UID view , we need this ID saved in a cookie for another solution, since this ID is only set once user logged in. Thank you, Pradeep

How to pass a cookie values as custom dimension?

Employee Emeritus
glad to help!
Public