Headstream

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.

  1. Find your key in the snippet under Project settings. It's the data-key value, starting with hs_.
  2. In GTM, create a new tag and pick Custom HTML.
  3. Paste this, using your own key and the src from 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>
  1. Set the trigger to All Pages.
  2. 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.

See which marketing makes money.

Get started free