Highlighted

Simple(ton) question: syntax for utag_data is var utag_data = {name:"value"} or var utag_data = {"name":"value"} or either?

Rookie Contributor
 
3 REPLIES 3
Highlighted

Simple(ton) question: syntax for utag_data is var utag_data = {name:"value"} or var utag_data = {"name":"value"} or either?

Tealium Employee
Hi Patrick, Our best practice is to not include quotes in the key, but do include quotes for the value, just like the first example. However, either works.
Highlighted

Simple(ton) question: syntax for utag_data is var utag_data = {name:"value"} or var utag_data = {"name":"value"} or either?

Tealium Employee
Dan, It is actually better practice to have the quotes around the name. This stops issues arising when reserved words or invalid characters are used. From Douglas Crockford: JavaScript, The Good Parts. A propertyâ s name can be any string, including the empty string. The quotes around a propertyâ s name in an object literal are optional if the name would be a legal JavaScript name and not a reserved word. So quotes are required around "first- name", but are optional around first_name. Adrian
Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.
Highlighted

Simple(ton) question: syntax for utag_data is var utag_data = {name:"value"} or var utag_data = {"name":"value"} or either?

Tealium Employee
Adrian is correct. I've been out of TiQ deployments too long to see that we do indeed recommend quotes. Thanks for the reply, Adrian.