- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
As a best practice, Tealium recommends that you develop a robust Universal Data Object (UDO) to encompass all of your data points. However, we recognize that sometimes it is easier for you to maintain and leverage an existing data object in conjunction with the UDO.
Referencing a UDO variable with the JavaScript Code Extension is syntactically simpler that referencing a variable outside the UDO.
To abide by Tealium's best practice of using a single UDO you would have to transfer all of the variables in your current data object to the Tealium UDO. This can take some time, depending on your development cycle. This solution may be faster.
If you plan to use the utag.link() and utag.view() functions directly, as a best practice we recommend referencing the UDO rather than another data object.
NOTE: Your page's source code will not change as a result of merging the data objects as described below. The data object will appear merged in the DOM instead.
So, let's say that you or your client is a current SiteCatalyst user, but will be switching over to Tealium in the near future. And let's say that you or your client does not want to (or cannot) remove the "s." objects from the page, but instead would like to continue updating the "s." object variables as you have in the past. There is a solution that will allow you to keep the "s." object on the page, allow you to update it, and still allow you use those variables in conjunction with the "utag_data" object that you will use for your other Tealium-managed Tags.
In order to maintain your "s." object and merge the "s." object and the utag_data object, you will need to follow three steps:
Declare the "s" object so that your page doesn't throw an error when it comes across the "s." variables. You can add this declaration to the page code itself, or place the declaration in the "utag.sync.js"/"utag.footer.js" file and then place the file somewhere before the first "s." variable is defined. The declaration for the s object is simply:
var s = s || {};
Add a JavaScript Code Extension in Tealium iQ that contains the code needed to merge the two objects.
Add the merge code into the Pre-Loader extension you just created. The code you use depends on whether or not your site uses jQuery.
For sites with jQuery, insert the following code:
if (typeof s == "object" && typeof utag_data == "object"){ utag_data = jQuery.extend({}, utag_data, s)}
Which will look like this in Tealium iQ:
You can read more about this jQuery method here.
Note: This code has been tested and works on all previous jQuery versions back to 1.0.
For sites without jQuery, there is a JavaScript alternative:
if (typeof s == "object" && typeof utag_data == "object"){ for (key in s) { utag_data[key] = s[key]; } };
Which will look like this in Tealium iQ:
Copyright All Rights Reserved © 2008-2023