- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-29-2017 01:46 AM - edited 08-30-2017 06:24 AM
Hi all,
For those of you who might be interested, I have created a very minimal Profile and Environment switcher bookmarklet.
I wanted to have an environment switcher that just did the job, while being browser-agnostic and easy to use.
That led me to create this bookmarklet "TiQ Switch", including the use of JavaScript alerts and prompts, which I normally don't use anymore ;-).
The account used it "hard set" in the script code, but all you have to do to change to another profile and/or environment to enter a valid [profile]/[Environment] value in the input field and click the button below that field.
Then the page reloads using the new profile/enviroment.
If you enter value in the correct format, but for a non-existing profile and/or environment, you will "remove" Tealium iQ from your currently debugged pages.
Remove Tealium iQ cookies from you domain to fix that, preferably only the enviroment switcher cookie, being named in a profile/environment name format.
If you have any problems using either below bookmarklet code or non-bookmarklet code, then please refer to the mentioned GitHub repository.
Enjoy!
TiQ Switch screenshots
Sorry about the Danish word "Siger" in the above screenshots ;-)
It actually just means the same as "says" in English.
My browser just felt that it needed to write it in Danish.
The bookmarket
I can't seem to add the bookmarklet as a link in this message.
But you can grab the link code here, or look at the GitHub repository, which also includes the "non-garbled" non-bookmarlet version.
javascript:void%20function(){if(%22object%22==typeof%20utag){var%20t=prompt(%22New%20Tealium%20iQ%20environment%3F%22,utag.data[%22ut.profile%22]+%22/dev%22);if(/^(\w|[-_])*\/(\w||[-_])*$/.test(t)){for(var%20e=document.cookie.split(/=[^;]*(%3F:;\s*|$)/),a=0;a%3Ce.length;a++)/^utag_env_/.test(e[a])%26%26(document.cookie=e[a]+%22=;%20expires=Thu,%2001%20Jan%201970%2000:00:00%20GMT;%20path=/%22);document.cookie=%22utag_env_%22+utag.data[%22ut.account%22]+%22_%22+utag.data[%22ut.profile%22]+%22=//tags.tiqcdn.com/utag/%22+utag.data[%22ut.account%22]+%22/%22+t+%22/utag.js%22,window.location.reload()}else%20alert(%22Input%20not%20entered%20correctly!\r\rPlease%20enter%20in%20the%20following%20format:\rPROFILE/ENVIRONMENT\r\rExample:\rtest-site/dev\r%22)}else%20alert(%22Telium%20iQ%20not%20found%20on%20page!%22)}();
Add a bookmark to your browser and put the above code in there, to be able to use the bookmarklet yourself.
A "non-garbled" non-bookmarlet version
// Check for utag object if (typeof utag === 'object') { var newEnviroment = prompt('New Tealium iQ environment?', utag.data['ut.profile'] + '/dev'); if (/^(\w|[-_])*\/(\w||[-_])*$/.test(newEnviroment)) { // Get an array of all cookie names (the regex matches what we don't want) var cookieNames = document.cookie.split(/=[^;]*(?:;\s*|$)/); // Remove any that match the pattern for (var i = 0; i < cookieNames.length; i++) { if (/^utag_env_/.test(cookieNames[i])) { document.cookie = cookieNames[i] + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; } } // Set new environment cookie, and reload page document.cookie = 'utag_env_' + utag.data['ut.account'] + '_' + utag.data['ut.profile'] + '=//tags.tiqcdn.com/utag/' + utag.data['ut.account'] + '/' + newEnviroment + '/utag.js'; window.location.reload(); } else { alert('Input not entered correctly!\r\r' + 'Please enter in the following format:\r' + 'PROFILE/ENVIRONMENT\r\r' + 'Example:\r' + 'test-site/dev\r'); } } else { alert('Telium iQ not found on page!'); }
Check it out at GitHub
https://github.com/pmeyerdk/tiq-switch
Feel free to use, comment and modify.
But please let me know if you find it useful, or chose to upgrade or modify it.
Let's share and make each other smarter :-)
Please also share knowledge about other helper tools for implementing or debugging Tealium iQ implementations.
Best regards,
Peter Meyer
08-29-2017 06:17 AM
GREAT stuff @pmeyerdk! I love it!
There is a complete list of Tealium Tools! And that's all I've got. Anybody else want to share?
Copyright All Rights Reserved © 2008-2023