examples/astro-ssr (Astro 7.3.8 with @astrojs/node in
standalone mode), which runs in the browser test matrix.
Where the tag goes
Put the tag in the<head> of the layout every page uses, for example src/layouts/Base.astro.
The example renders the tag from the environment so that tests can use their own site id:
<script> that has no attributes other than src, but leaves a
script with any other attribute exactly as written. The tag has several (defer, integrity,
crossorigin, data-website-id), so it reaches the browser unchanged: with Astro 7.3.8 a page
holding this literal tag rendered it byte for byte (checked by hand on 2026-11-13; the example
itself emits the tag through set:html, which its test checks). Do not move the tag into a
component script.
Each full page load is one pageview. View transitions (<ClientRouter />) are not part of the
example and were not tested.
Custom events
data-umami-event attributes work in any template. For a call from page code, use a script with
is:inline, so Astro does not bundle it and it can read window.umami:
What the browser tests check
One pageview per server-rendered page load, the page title from the layout’s<title>, both kinds
of custom event, an external referrer on the first pageview, Global Privacy Control and a tampered
tracker refused (tests/e2e/specs). View transitions are not part of the example.