Highlighted

How to reduce / combine cookies (extension available / possible)?

Rookie Contributor
Hi, on our website we have too many cookies already and always try to reduce them as much as possible. As we have several use cases where we need to hand over values from page to page or make values persistent this would leed to multiple cookies, which we want to avoid. Is there a way to combine the (some/ certain) cookie variables from the data layer into one "physical" cookie instead of spamming the user with a lot of cookies? sebastian
3 REPLIES 3
Highlighted

How to reduce / combine cookies (extension available / possible)?

Tealium Employee
Hi Sebastian, This is possible using built in methods within the uTag code. (utag.loader.SC). A simple example would be: {code:js} utag.loader.SC("utag_test",{ "parameter1": "value1;exp-1d", "parameter2": "value2;exp-1d" }); {code} This would set a cookie with the name utag_test and the value: parameter1:value1$parameter2:value2 This would add the values you have defined in the object to the utag_main cookie. You can use any name for the cookie but if you wish to pass multiple values in the format of an object, the cookie name needs to be prefixed with "utag_" else the function will only accept a non-object argument like so: {code:js} utag.loader.SC("HRS", "a string"); {code} This will set a cookie with the name "HRS" and the value "a string". If you wish we can discuss this in more detail on our call later today. Kind Regards Simon
Highlighted

How to reduce / combine cookies (extension available / possible)?

Rookie Contributor
Hi Simon, can you please also document how to read multiple variables from a cookie combined in this way? sebastian
Highlighted

How to reduce / combine cookies (extension available / possible)?

Tealium Employee
Hi Sebastian, By default the uTag javaScript will append all cookie values to the UDO on initialisation. So in the UDO you would have the following: {code:js} utag.data = { cp.utag_test_parameter1: "value1", cp.utag_test_parameter2 : "value2" } {code} This can then be called through the b object (during an All Tags extension or Tag scoped extension). Or through the utag.data {code:js} b["cp.utag_test_parameter1"] utag.data["cp.utag_test_parameter2"] {code} There is another method that you can use which is the utag.loader.RC. By passing in the name of the cookie you wish to interact with it will return a JSON object (or string if a cookie not prefixed with utag /ulog) that you can then interact with: {code:js} var tmp = utag.loader.RC("utag_test"); {code} Simon