Reading a cookie into the Data Layer, Tealium Tools Web Companion

Hey guys,


I was just trying to write a little extension that shall display a message at the top of our web page when the environment of the utag.js gets changed in the Tealium Tools Webcompanion extension (Chrome).


My initial approach was to add a property to the data layer, using the cookie name the Webcompanion writes.

Settings are

  • Source utag_env_mycompany_main
  • Type First Party Cookie
  • Alias some alias

The problem is that when I set the environment to let's say "dev", Tealium does not seem to properly generate/populate this datalayer value. Instead the propertey name seems to get the actual value appended to it, leaving the value unset.


cp.utag_env_mycompany_main_// : "undefined"


Any idea, what's wrong here?


Cheers, Bjoern

Accepted Solutions (1)

Accepted Solutions (1)


Seems like the cookie is not getting parsed correctly into the datalayer. 


There is a built in feature in since version 4.36 of utag.js which has the environment already in the data layer:


In Tealium iQ, you can add these "Tealium Built-in Data" Data Sources via the "Add Common Data Sources" in the "Data Layer" tab. 


With this approach, you can look at:['ut.env']


Or you can pull the value of the cookie using the following:

webCompaionVersion = (function (sKey) {
    if (!sKey) { return null; }
    return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;



Employee Emeritus

Answers (0)