- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
06-07-2016 12:21 AM
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
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_//tags.tiqcdn.com/utag/mycompany/main/dev/utag.js : "undefined"
Any idea, what's wrong here?
Cheers, Bjoern
Solved! Go to Solution.
06-07-2016 10:29 AM
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:
https://community.tealiumiq.com/t5/uTag/utag-js-Versions-4-33-through-4-40-Release-Notes/ta-p/11909
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:
utag.data['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; }('utag_env_'+utag.data['ut.account']+'_'+utag.data['ut.profile']))
06-07-2016 10:49 PM
Copyright All Rights Reserved © 2008-2023