Skip to content
Frameworks

Astro analytics with revenue attribution

2 min read · Updated · By the Reveata team

Short answerPaste the Reveata snippet with is:inline into the Astro layout that renders the head of every page. Astro then leaves the tag as written, view transitions are tracked, and payment links or checkouts started from your pages are credited to the visit behind them.

Astro sites are fast, mostly static and often content-led: docs, blogs, marketing sites for a product. Reveata keeps that spirit: one deferred script in the base layout, no client framework required.

What you get

  • Every page counted, including page changes made with view transitions (<ClientRouter />).
  • Goals from a data-reveata-goal attribute in any .astro component, or from a script.
  • Revenue by page and channel, from payment links on your pages or a checkout endpoint of your own.
  • First-party serving through Astro endpoints, your host's rewrites or the managed proxy.

How to install it

In the layout that renders <head> for every page, add:

astro
<script is:inline defer data-website-id="ws_your_tracking_id" src="https://reveata.com/js/script.js"></script>

is:inline matters. Astro processes and bundles plain <script> tags, which can move the script or drop its data-* attributes; is:inline leaves it exactly as written. Astro explains this in its client-side scripts guide (opens in a new tab). If you have several layouts, each one that renders <head> needs the snippet, or a shared head component.

Serving it from your own domain

How the site is deployed Option
With a server adapter (Node, Vercel, Netlify, Cloudflare) Two endpoints in src/pages: Proxy with Astro
Static, on Vercel, Netlify or Cloudflare The host's rewrites: Proxy through your own server
Behind NGINX or Caddy NGINX or Caddy
Anywhere with a custom domain The managed proxy, one DNS record

Serving the script from your own domain means fewer visits are lost to ad blockers.

Linking payments to visits

Most Astro sites link to a hosted checkout. Links to Stripe Payment Links and Buy Buttons get the visitor id when clicked, with no code (Stripe Payment Links analytics). If an endpoint of your own creates the checkout, send window.reveata.metadata() with that request and put the two ids into the checkout metadata. With your own billing, use the Payments API.

Frequently asked questions

Does a fully static Astro site work?

Yes. The script runs in the browser, so static output is fine. Only the proxy endpoints need a server adapter.

Can I build the tag from options?

Yes. @reveata/next/snippet builds the same tag from options, with no React dependency.

Why don't I see visits from my dev server?

The script ignores localhost unless you add data-allow-localhost="true".

See it with your own numbersReveata ties every visit and sale to the source that brought it. Add your website in a minute.
Get started
Was this page useful?
IntegrationStripe Payment Links analytics without codeThe Reveata script adds the visitor and session ids to every Stripe Payment Link, Buy Button and Pricing Table on your pages as a client_reference_id. Stripe stores it on the payment, and Reveata uses it to credit the sale to the visit, with no code to write.IntegrationAngular analytics with ReveataPaste the Reveata snippet before the closing head tag of src/index.html. ng build keeps it in the built page, server-side rendering included, and the Angular Router's History API navigation is counted automatically. HashLocationStrategy needs data-hash="true".IntegrationDjango analytics with revenue attributionPaste the Reveata snippet before the closing head tag of the base template your Django templates extend. Every page is tracked, the Django admin is not, and two hidden form fields let your checkout view put the visitor id into the payment's metadata.IntegrationDocusaurus analytics for documentation sitesAdd the Reveata script to the scripts array in docusaurus.config.js, or build the entry with @reveata/next/snippet. Page changes inside the docs are tracked by the script, so every page a reader opens is counted.IntegrationExpress.js analytics with a first-party proxyPaste the Reveata snippet into the layout, static HTML or front-end index.html your Express app serves. Two Express routes can serve the script from your own domain with your proxy secret, and your checkout route can copy the visitor id into the checkout metadata.IntegrationFastAPI analytics with ReveataPaste the Reveata snippet into the base Jinja2 template of your FastAPI app, or into the index.html of the front end FastAPI serves. Two FastAPI routes can serve the script from your own domain, and your checkout endpoint can put the visitor id into the payment's metadata.