Add whoisbrowsing to Astro
Updated
TL;DR
To add whoisbrowsing to Astro, put one script tag in the <head> of the layout component that your pages share, usually src/layouts/Layout.astro. Every page that uses the layout then loads it.
Using an AI coding agent? Give it this prompt:
Add whoisbrowsing (live visitor view) to this project. Follow https://whoisbrowsing.com/SKILL.md exactly.
Add the tag to your layout
Astro layouts are components that provide the page shell, including <head>, with a <slot /> for each page's content (Astro layouts). Add the tag there:
---
// src/layouts/Layout.astro
const { title } = Astro.props;
---
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>{title}</title>
<script is:inline src="https://live.whoisbrowsing.com/s.js" data-site="YOUR_SITE_ID" defer></script>
</head>
<body>
<slot />
</body>
</html>
Outside Astro, it is the same plain tag every guide uses:
<script src="https://live.whoisbrowsing.com/s.js" data-site="YOUR_SITE_ID" defer></script>
is:inline tells Astro to leave the tag exactly as written instead of bundling it. Astro applies it automatically when a script has extra attributes, but writing it out makes the intent clear.
View transitions
If you use Astro's view transitions (the client router), pages change without a full reload. Per the Astro view transitions docs, some scripts re-run after a navigation and bundled module scripts run only once. Leave data-astro-rerun off this tag. You want it to load once and keep running, and it follows each page change on its own.
Where to get your site ID
Open /try to create a site with no sign-in (you can claim it later), or sign in with Google. You get a site ID to replace YOUR_SITE_ID in the code above. Each website is separate: localhost and production never mix, and www. is the same website as the bare domain.
Navigation between pages
Astro apps change pages in the browser without a full reload. You do not need extra code: the script follows client-side route changes on its own, so each page a visitor moves to shows up in your live view.
Content-Security-Policy
If your site sends a Content-Security-Policy header, allow the script and its live connection:
script-src https://live.whoisbrowsing.com;
connect-src wss://live.whoisbrowsing.com;
Add these to your existing script-src and connect-src lists instead of replacing them. If you have no CSP, skip this step.
Verify
- Deploy, or run your site locally. Use the site ID made for that address, because localhost and production are separate websites.
- Open the whoisbrowsing dashboard and click Watch.
- Open your site in a Chrome Incognito window or a Safari private window. Your own normal browser is never counted, so a private window is how you test as a visitor.
- You should appear as a coloured cursor on your real page, with a line for you in the side panel.
If nothing shows up, check that the tag is in the page source, that the site ID matches the address you opened, and that a CSP or ad blocker is not stopping live.whoisbrowsing.com. See how it works for what is sent, and the privacy page for what is never sent or stored.
Let your AI agent do it
Paste this into Claude Code, Cursor or Codex:
Add whoisbrowsing (live visitor view) to this project. Follow https://whoisbrowsing.com/SKILL.md exactly.
The agent reads the instructions, creates a site, puts the tag in the right file for Astro and gives you a watch link. The full walkthrough is in Install with an AI agent.
More install guides
See every platform on the install page, or jump to Next.js and React. Prefer to try first? Open /try. To see what the tag does, go to the home page.