Install TayStack with Google Tag Manager
Load the TayStack script from a Google Tag Manager custom HTML tag, and why adding it to the page directly is simpler.
Not tested: Not yet tested on a live site using Google Tag Manager. The steps follow how the platform is documented to work. Menu names change, so look for the setting described rather than the exact words.
If you can edit the head of your pages, add the tag there instead: it is simpler and loads sooner. Use Tag Manager only when that is the one place you can change. The script reads its settings from its own tag, so the custom HTML tag below creates the tag itself, with the same attributes.
Replace site_xxxxxxxx and your-domain.com with your own site id and domain. The dashboard's Install card shows the tag with your values filled in.
Add the script
- In your container, create a new tag of the type Custom HTML.
- Paste the code below into it.
- Set the trigger to fire on all pages (the page view trigger), and fire the tag once per page.
- Save, then publish the container.
<script>
;(function () {
var s = document.createElement('script')
s.defer = true
s.src = 'https://www.taystack.com/js/script.js'
s.setAttribute('data-website-id', 'site_xxxxxxxx')
s.setAttribute('data-domain', 'your-domain.com')
document.head.appendChild(s)
})()
</script>Check it works
- Publish or deploy the change, then open your site on its real domain. Test addresses and editor previews may not match the domain you registered, and
localhostis not tracked. - Sign in, open your site in the dashboard and look at the Installation status. It reads “Waiting for the first event” until an event arrives, then “Receiving data”. It checks every few seconds while the page is open; the Verify installation button checks straight away.
To look at the request itself, follow the steps in Quick start.
If it does not work
- Tag Manager is itself blocked by some ad blockers, and then nothing it loads runs.
- Changes in Tag Manager apply only after you publish the container. Preview mode does not change your live site.
- The tag loads after Tag Manager does, so it may start a little later than a tag in the head. A script added from JavaScript loads without blocking the page.
- Ad blockers: some block analytics scripts and the script fails silently. Test in a private window with extensions off. See Troubleshooting.
- Content Security Policy: if your site sends a
Content-Security-Policyheader,script-srcmust allowwww.taystack.comandconnect-srcmust allow it too, because events are sent there. - Caching: a page cache or CDN may still serve the old HTML without the script. Clear the cache, then reload.
- Both
data-website-idanddata-domainmust be present and match your site, or the script does nothing. More in Troubleshooting.
Back to all install guides.