Measure visits
Turn on first-party metrics, Cloudflare Web Analytics, or consent-gated marketing tags. Each layer is off until you configure it.
Send first-party metrics to your endpoint
Set
metrics.endpointinsrc/site.config.tsto anhttps:URL you control.export const site: SiteConfig = { metrics: { endpoint: 'https://metrics.example.com/collect' }, };Accept
POSTrequests there with a JSON body sent astext/plain. Metrics beacons lists every body the script sends.Build and open a page. The engine's
Footer.astrocarries one small inline script, and your endpoint receives a pageview. A site that replaces the footer with its own has to renderMetrics.astrofrom@gronare/stomme/Metrics.astroitself, or no beacon is sent.
The script sets no cookies and uses no localStorage, so it needs no consent banner. It stays silent under automated browsers. Left unset, or set to an address that is not https:, nothing is emitted and the script is not in the HTML.
Add Cloudflare Web Analytics
Create a site in Cloudflare Web Analytics and copy its token.
Set it as
analytics.cfToken.export const site: SiteConfig = { analytics: { cfToken: 'your-token' }, };Build. Every page loads Cloudflare's beacon script in its head.
The beacon reports only when the site is served through Cloudflare, so it suits build:cloudflare or a site proxied by Cloudflare.
Add Google Tag Manager, GA4 or a Meta Pixel
Turn the flag on in
src/site.config.ts.export const features: StommeFeatures = { tracking: true };Run
pnpm stomme cms, then fill in the tag IDs and the privacy page in the CMS's tracking settings, or insrc/content/tracking/tracking.md.gtmId: GTM-XXXXXXX ga4Id: G-XXXXXXXXXX metaPixelId: "" privacyUrl: /privacyBuild and open the site. The consent banner appears, and the tags load with Google's consent mode set to denied and the Meta Pixel's consent revoked. Accept grants both, and the choice is remembered in the visitor's browser.