How to track visitors on Astro.
An Astro integration, added to your config once. It covers static and server-rendered pages the same way.
What you need
- • An Astro project.
- • A VisitorPing site key, in the form vp_ABC23456 — the prefix vp_ and eight characters. The alphabet leaves out I, O, 0 and 1, so there is nothing to misread when copying it.
Install it
- 1
Add the integration
The Astro CLI installs and registers it in one step.
npx astro add @visitorping/astro # or pnpm add @visitorping/astro - 2
Set your site key
Add the integration to astro.config.mjs with your key.
import { defineConfig } from "astro/config"; import { visitorping } from "@visitorping/astro"; export default defineConfig({ integrations: [ visitorping({ siteKey: "vp_ABC23456", }), ], }); - 3
Rebuild and check
Rebuild and deploy, then open the site in a private window and view the source. The tag should be in the head of every page.
What you will actually see
Per visit: the city and region the network resolves to, where the visitor came from, the page they landed on, their device and browser, and whether they have been before.
You do not get a name, an email address, or an identity. Nobody can give you that from a page view, whatever the marketing says. Geolocation resolves a network rather than a doorstep, so a visitor on a VPN or a mobile network can appear in the wrong city entirely. Treat location as a hint.
You are collecting visitor data, so say so in your privacy notice and check which consent rules apply where your customers are — a question for your own legal advice, not for a setup guide.
If it is not working
- The tag is missing after deploying
- Astro config is read at build time. Changing it and redeploying the previous build changes nothing — rebuild.
- Some pages have it and others do not
- Pages rendered outside the Astro pipeline, such as a hand-written file in public/, do not go through integrations. Those need the plain script tag.
Find what is costing you search clicks, then watch the fix work.
VisitorPing reads your own Search Console data for the pages losing clicks, then rings your phone the moment someone lands on your website.