Can't include tracker via Google Tag Manager
Including userTrack through Google Tag Manager is not recommended. Google Tag Manager is blocked by ad-blockers, which means that userTrack will fail to load too.

Problem:

Including the userTrack tracking script via Google Tag Manager doesn't work.
Uncaught TypeError: Cannot read property 's' of undefined at ust.min.js?v=3.4.2:2

Cause:

The issue occurs because when you include multiple scripts via GTM, the include order is not guaranteed.
The default way to include userTrack
1
<script>UST_CT = [];UST = { s: Date.now(), addTag: function(tag) { UST_CT.push(tag) } };UST.addEvent = UST.addTag;</script>
2
<script src="https://your.usertrack.com/server/ust.min.js?v=x.x.x" async></script>
Copied!
With Google Tag Manager, the second <script> tag might be loaded before the first one.

Solution:

A quick solution is to use a single script tag and load ust.min.js dynamically like this:
Single-script way to include userTrack
1
<script>UST_CT = [];UST = { s: Date.now(), addTag: function(tag) { UST_CT.push(tag) } };UST.addEvent = UST.addTag;
2
var ust_min_js = document.createElement("script");
3
ust_min_js.src = 'https://your.usertrack.com/server/ust.min.js?v=x.x.x';
4
document.head.appendChild(ust_min_js);
5
</script>
Copied!
Make sure to replace https://your.usertrack.com/server/ust.min.js?v=x.x.x with the actual URL to your tracking file.
โ€‹
Last modified 1mo ago
Copy link