Where to place utag.js on a static page without an explicit UDO?

michael_sievers
Silver Contributor
Silver Contributor michael_sievers

Hello,

I have a question concerning the placement of utag.js in a static HTML document without UDO.

The aim is to add Tealium to parts of a web site where the modification of source code is expensive due to process reasons. Adding utag.js as a one off process is feasible, building a best practice conforming UDO is economically forbidding.

Tealium will mainly be used to extract information from the corresponding web pages and feed that into a Collect Tag. The information on the page will be present in javascript variables and the DOM. Timing is not essential, but being sure that the javascript variables on the page are accessible to Tealium is.

My question is: where should we best place the utag.js call in this case, right below the opening body tag (usually best practice) or at the bottom of the page, below all the (static) data and javascript variables?

What would be the advantages, disadvantages of the two solutions?

I am leaning towards placing the utag.js at the bottom, so that we know that all data is present on the page when TiQ runs and we can immediately use an extension to set the data values in the data layer. As opposed to, say, placing utag.js at the top and firing the Tags on DOM Ready and scoping the data setting Extensions to the relevant tags, hoping that they will have the correct timing.

Is there a recommendation on utag.js placement under these circumstances?

Thanks in advance,
Michael

2 REPLIES 2

Where to place utag.js on a static page without an explicit UDO?

Tealium Employee
Hi @michael_sievers,

To give you the most flexibility, I would still say to place utag.js at the top of the body, but use one of the override flags available in utag.js to force it to wait until "DOM Complete" before firing any tags. This will mean that the data is going to be available, but if you do need to run a tag sooner (perhaps one that has very few or no mappings), you could turn off the "wait" flag and have that tag load sooner than the rest.

Here's a full list of overrides available in utag.js, including the dom_complete flag: https://community.tealiumiq.com/t5/Browser-utag-js/utag-Config-Overrides/ta-p/14048

I hope this helps.

Craig.
Check out our new Swift integration library for iOS, macOS, tvOS and watchOS: https://github.com/Tealium/tealium-swift with updated
documentation https://community.tealiumiq.com/t5/Swift/tkb-p/swift.

Where to place utag.js on a static page without an explicit UDO?

michael_sievers
Silver Contributor
Silver Contributor michael_sievers

Hello @craig_rouse,

that sounds perfect, we will do it this way!

Thanks,

Michael