Google Tag Manager
Updated 2026-11-02
Setup
GTM can remove custom attributes when it writes a tag to the page, and Headstream needs data-key. So use a small loader that sets the attribute itself.
- Find your key in the snippet under Project settings. It's the
data-keyvalue, starting withhs_. - In GTM, create a new tag and pick Custom HTML.
- Paste this, using your own key and the
srcfrom your snippet:
<script>
(function () {
var script = document.createElement("script");
script.src = "https://headstream-ingest.super-dream-7005.workers.dev/t.js";
script.setAttribute("data-key", "YOUR_KEY");
document.head.appendChild(script);
})();
</script>
- Set the trigger to All Pages.
- Use Preview to confirm that the tag fires, then Submit to publish.
Don't install it twice
If the script is also in your site's code, you'll record every pageview twice. Keep one or the other.
Single-page sites
Don't add a history change trigger. The script tracks route changes on its own, and firing the tag again would load a second copy.
Send events from GTM
Add another Custom HTML tag for an event, with whatever trigger you like:
<script>
window.headstream && window.headstream.track("demo_click");
</script>
The script loads asynchronously, so an event fired right at page load can run before it's ready. Use interaction triggers, such as clicks and form submissions.
Forms are read automatically on submit, so you don't need tags for email, name or heard_about.
Check it works
Publish, then load your live site and check your project's setup status. Note that blockers that stop GTM will stop this tag too. If that matters for your audience, install the script directly, using first-party tracking.