Installation guides
Install on Replit
On this page
Ask Replit Agent to add the tag, or paste it into your app's HTML head, then publish.
Ask Agent
Send this prompt to Agent
Replace
YOUR_SITE_IDwith the public site ID from your site's Settings → Install card. The site ID is public and safe in browser code; never put your secret key in a page.PromptAdd this analytics script to every page of the app. Load it once for the whole app, in index.html or the root layout (with next/script in a Next.js app), never from a single page or component. Keep the src and data-site-id attributes exactly as written: <script defer src="https://metricraven.com/js/script.js" data-site-id="YOUR_SITE_ID"></script>Publish
Choose Publish at the top right of the workspace (or republish). The development preview is a private, temporary URL that isn't your live app.
Or edit the file yourself
Open the file that renders your page head and paste the tag before </head>:
- A Vite or plain HTML app:
index.html(in full-stack apps it may sit in aclientfolder). - Next.js: follow the Next.js guide.
- Flask or Django: your base template; see Django.
<script
defer
src="https://metricraven.com/js/script.js"
data-site-id="YOUR_SITE_ID"
></script>Verify it works
Open your live website in a normal browser window (not an automated or embedded one). In the browser's Network panel, look for script.js and then a request to /api/v1/collect whose response contains ok: true. Open your site's Traffic tab and choose Refresh; the selected dates must include your visit.
Nothing showing? See Troubleshooting.
Notes
- Only hostnames listed in your site's Settings → General → Site domains (and their subdomains) are accepted. To also count visits on a platform address such as
your-app.replit.app, add it there; otherwise those requests are refused withdomain_not_allowed. - On the Starter plan a published app expires after 30 days. When it does, tracking stops with it.
- AI edits can drift. After each publish, open your live app, view the page source and check the tag is still in
<head>with itsdata-site-idunchanged. - Click between a few pages and check the Network panel shows one
/api/v1/collectpageview per navigation. Two per click means the tag is loaded twice.
Optional script attributes are listed in Install & verify. To exclude your own visits, see Exclude your visits.