Install on Astro
View as MarkdownAdd Reveata to the base layout of an Astro site, proxy it through your own domain, and credit payments to their visits.
On this page
Astro pages share a base layout that renders <head>, so the snippet goes there once.
Add it to your site
Paste the snippet in the layout that renders <head> for every page:
---
// src/layouts/Base.astro
---
<head>
<script
is:inline
defer
data-website-id="ws_your_tracking_id"
src="https://reveata.com/js/script.js"
></script>
</head>is:inline keeps Astro from bundling the script, so its data-* attributes stay on the tag. With view transitions (<ClientRouter />), page changes are tracked by the script.
Or build the tag with @reveata/next/snippet (npm install @reveata/next):
---
import { htmlSnippet } from '@reveata/next/snippet';
const reveata = htmlSnippet({ websiteId: 'ws_your_tracking_id', host: 'https://reveata.com' });
---
<head>
<Fragment set:html={reveata} />
</head>Check it works
Deploy, open your site in a normal browser window with ad blockers turned off for it, then open Realtime in Reveata: your visit appears within a few seconds. If it doesn’t, view the page source and check that the tag is there with its data-website-id, then follow Verify your installation.
Goals
Add data-reveata-goal="signup" to a button or link in any .astro component, or call window.reveata?.('goal', 'signup') from a script. See Custom goals.
Serve it from your own domain
- With a server adapter (Node, Vercel, Netlify, Cloudflare), two endpoints in
src/pagescan pass the script and events through your own domain: see Proxy with Astro. - A static site can use its host’s rewrites (Vercel, Netlify, Cloudflare Workers), NGINX or Caddy (Proxy through NGINX, Proxy through Caddy), or the managed proxy.
Revenue
Connect your payment provider in Reveata: see Connect a payment provider. Links on your pages to Stripe Payment Links and Buy Buttons are credited to their visit with no code (Stripe Payment Links and buy buttons). If an endpoint of your own creates the checkout, send window.reveata.metadata() from the browser with that request and put the two ids in the checkout metadata, as Install on React Router shows for an action. To send payments from your own code instead, use the Payments API.
Common pitfalls
- A processed script. Keep
is:inlineon the tag. Astro processes and bundles plain<script>tags, which can move the script or change its tag;is:inlineleaves it exactly as written. - Several layouts. Each layout that renders
<head>needs the snippet, or one shared<Head>component that all of them use. - Testing on localhost. The script ignores
localhostunless you adddata-allow-localhost="true".