Reply
Contributor
Posts: 121
Registered: ‎11-06-2015
Accepted Solution

Setting a utag_main cookie value to a dynamic parameter

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?

 

Reply
0 Kudos
Occasional Contributor
Posts: 121
Registered: ‎12-11-2015

Re: Setting a utag_main cookie value to a dynamic parameter

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.

Contributor
Posts: 121
Registered: ‎11-06-2015

Re: Setting a utag_main cookie value to a dynamic parameter

That effectively solves my problem. Wonderful, thank you!
Tealium Employee
Posts: 53
Registered: ‎08-14-2017

Re: Setting a utag_main cookie value to a dynamic parameter

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!
Reply
0 Kudos
Highlighted
Contributor
Posts: 121
Registered: ‎11-06-2015

Re: Setting a utag_main cookie value to a dynamic parameter

did that now, sorry
Tealium Employee
Posts: 53
Registered: ‎08-14-2017

Re: Setting a utag_main cookie value to a dynamic parameter

Yay @loldenburg! #hugs

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