- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-09-2017 10:04 AM
For some debugging purposes, it is helpful to send error messages to our error tracking tool or the console, but we want to do this only on non-production environments for most errors.
So usually we refer to a function that does this logging for us depending on whether window.console is not undefined and whether we are not on production (utag.data["ut.env"] !== "prod").
In Pre-Loader Scope, ut.env is not available. What ways do I have to check what environment I am on there?
Solved! Go to Solution.
08-09-2017 11:22 AM
Hi @loldenburg
That is correct, Pre-loader scoped extensions are ran before the Tealium library runs so utag is unavailable.
You would need custom code to scrape the page and check for /dev/ or /qa/ utag.js. Something like:
a=document.getElementsByTagName("script");
for (var i=0; i<a.length; i++){
if(a[i].src.indexOf("/dev/utag.js") > 0 || a[i].src.indexOf("/qa/utag.js") > 0) {
console.log(a[i].src);
}
}
Hope this is helpful.
Cheers,
-Dan
08-10-2017 12:40 AM
08-15-2017 09:10 AM
Hi @loldenburg, you may want to try using the following to grab the current environment from a Pre-Loader Scoped Extension.
window["utag_data"] = window["utag_data"] || {};
window["utag_data"]["tealium_env"] = document.currentScript.src.split('/').reverse()[1];
This should be pretty compatible these last days , except for IE (#sigh), you may rely on the getElementsByTagName('script') as failover if document.currentScript is undefined for some reason.
Copyright All Rights Reserved © 2008-2023