Skip to main content
TayStack

Install TayStack on Astro

Add the TayStack script to the head of an Astro layout with is:inline, then check in the dashboard that events arrive.

Not tested: Not yet tested on a live Astro site. The steps follow how the platform is documented to work. Menu names change, so look for the setting described rather than the exact words.

Put the tag in the <head> of the layout that all your pages share. Add is:inline so Astro leaves the tag exactly as written instead of processing it.

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

Astro
---
// src/layouts/Layout.astro
---
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>My site</title>
    <script is:inline defer data-website-id="site_xxxxxxxx" data-domain="your-domain.com" src="https://www.taystack.com/js/script.js"></script>
  </head>
  <body>
    <slot />
  </body>
</html>

If some pages do not use that layout, add the tag to those layouts too. The script should be on the page once.

Check it works

  1. 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 localhost is not tracked.
  2. 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.
  3. Click through two or three pages of your site, then look at the dashboard again. Route changes are recorded without extra code, see Single-page apps.

To look at the request itself, follow the steps in Quick start.

If it does not work

  • astro dev serves from localhost, which is not tracked. Test on a built and deployed site.
  • 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-Policy header, script-src must allow www.taystack.com and connect-src must 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-id and data-domain must be present and match your site, or the script does nothing. More in Troubleshooting.

Back to all install guides.