Highlighted

Setting a utag_main cookie value to a dynamic parameter

Silver Contributor
Silver Contributor

We have some code where we loop through several parameter/value combination to set them into the utag_main cookie.

E.g.:

var dynamicpar = "parameter_name_for_this_loop";
utag.loader.SC("utag_main", {
[dynamicpar]: "somevalue"
});

This sets utag_main parameter to "parameter_name_for_this_loop":"somevalue". It works in most browsers, but not in IE11...

How can we set the name of a parameter in the utag_main cookie dynamically for all browsers? Is it possible at all?

 

5 REPLIES 5
Highlighted

Setting a utag_main cookie value to a dynamic parameter

Tealium Expert
Tealium Expert

Computed keys are a feature of ES6 and are not available in older JS implementations.

The easiest way to get it to just work would be:

var dynamicpar = "parameter_name_for_this_loop";
var cookie_payload = {};
cookie_payload[dynamicpar] = "somevalue";
utag.loader.SC("utag_main", cookie_payload);


Wherein you initialise an empty object, and then set the dynamic key to the desired value using the traditional mehod.

Highlighted

Setting a utag_main cookie value to a dynamic parameter

Silver Contributor
Silver Contributor
That effectively solves my problem. Wonderful, thank you!
Highlighted

Setting a utag_main cookie value to a dynamic parameter

Silver Contributor
Silver Contributor

I'd say @loldenburg that @UnknownJ deserves to have his post "Accepted as a Solution" #winkwink

If you liked it then you should have put a kudo on it!
Highlighted

Setting a utag_main cookie value to a dynamic parameter

Silver Contributor
Silver Contributor
did that now, sorry
Highlighted

Setting a utag_main cookie value to a dynamic parameter

Silver Contributor
Silver Contributor

Yay @loldenburg! #hugs

If you liked it then you should have put a kudo on it!