Self-hosting utag.js
This guide shows the configuration and workflow for self-hosting the utag.js files.
Before you begin, contact your Account Manager to verify the contracted terms for this feature on your account to ensure availability and appropriate licencing is maintained.
Overview
Tealium iQ publishes your utag.js
files to our servers. When utag.js
is implemented on your website, the file is sourced from tags.tiqcdn.com
. If you have requirements that prevent you from loading external JavaScript files (or have other restrictions) we offer the ability to self-host these files on your own server. The generated utag
files are still published to our servers, but they are also made available in a .zip
archive which can be easily transferred to your system.
The main difference in self-hosting is in the code snippet used to load utag.js
on your website. The domain and path to that file must be updated to reflect your server location that hosts the files. In the following example you can see the URL change from Tealium’s standard location to a self-hosted location.
Original Tealium snippet:
<!-- Tealium Universal Tag -->
<script type="text/javascript">
(function(a,b,c,d){
a='//tags.tiqcdn.com/utag/[ACCOUNT]/[PROFILE]/[ENV]/utag.js';
b=document;c='script';d=b.createElement(c);d.src=a;
d.type='text/java'+c;d.async=true;
a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a)
})();
</script>
Self-Host snippet:
<!-- Tealium Universal Tag -->
<script type="text/javascript">
(function(a,b,c,d){
a='//YOURDOMAIN.com/CUSTOM/PATH/[ENV]/utag.js';
b=document;c='script';d=b.createElement(c);d.src=a;
d.type='text/java'+c;d.async=true;
a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a)
})();
</script>
Enable the .zip archive
The first step is to enable the zip archive so that you can retrieve the necessary files from iQ. The zip archive is a file named distro.zip
that is created every time a publish occurs. It contains all the necessary files to run your instance of utag.js
. This file is not generated by default, so it must be enabled.
To enable the distro file:
- In the admin menu, click Configure Publish Settings. The Publish Configuration dialog appears.
- On the General Publishing tab, under the Implementation section, find the Generate distro.zip file setting and toggle it to On.
- Click Save
Set published file location
The published file location is a setting that tells the utag.js
code where to load subsequent utag files (for example, utag.4.js
). Remember, the code snippet to load utag.js
will be adjusted to use your custom self-hosted location, but the loading of the other utag files occurs dynamically based on the logic within utag.js
and the default location is Tealium’s servers.
To change the published file location:
- In the admin menu, click Configure Publish Settings. The Publish Configuration dialog appears.
- On the General Publishing tab, under the Publishing URLs section, enter the domain and full path to your self-hosted files, one for each environment (omit the actual file name) eg.
//example.com/custom/path/prod/
- Click Save
Include the environment in your path to support the built-in Dev, QA, and Prod targets.
Publish all environments
You have now enabled the downloadable distro.zip
file. You will notice that the code snippet in the Code Center now displays the custom location of your hosted utag.js
instead of Tealium.
The final step is to publish the profile to all environment targets (Dev, QA, Prod). This will ensure you have a distro.zip
file generated for each environment.
Publish work flow
You will continue to manage your tags within iQ, but each time you save and publish you will need to download the new distro.zip file and unzip the files to your own server.
To download and verify the distro.zip
file:
- From the Versions tab, find the last published version, expand the Publish Details for each environment and click Download Distro Zip File.
- Unzip the
distro.zip
file on your server in the location specified in the custom Publishing URLs setting. - Using the code from Code Center, add the
utag.js
code snippet to your website. - Using the browser console, verify that your webpage is loading utag.js from your self-hosted location and not from Tealium’s domain
tags.tiqcdn.com
.
Use version labels
Lastly, after you make the utag
files available on your live site, we recommend taking one last step to label the released version in iQ using Version Labels. This will indicate to users of your account which versions have completed your internal software release cycle.
SHA256 digest signatures
For extra security concerns, you can verify the contents of the files by clicking the Distro Verification link from the publish details area where you downloaded distro.zip
. This will show the SHA-256 checksums for each file in the archive.
Then you can use your favorite checksum utility to verify the digest signatures of the files on your hosted location. Here is the SHA-256 checksum for utag.js
, which matches the value seen in iQ.
This page was last updated: June 27, 2023