Hosts
CrispStats on Vercel: install and proxy
To use CrispStats on Vercel, add the script tag to your site's pages and deploy; Vercel needs no setting of its own. To count visitors whose ad blocker stops analytics hosts, add one route to vercel.json that forwards a path such as /k3x9qe/* to the collector and deletes the cookie and authorization headers on the way.
Updated
Set up CrispStats on Vercel
- 01
Step 1: Add the script tag to your site
Copy the tag from Settings, Tracking code in the dashboard and put it inside
<head>on every page, in your source code or layout. For a Next.js app, follow the Next.js guide instead, which usesnext/scriptand a route handler for the proxy.Replace the highlighted values with your own.
<scriptdeferdata-site="cs_pk_your_site_key"data-domains="example.com"src="https:/ / in. crispstats. com/ d. js"></script> - 02
Step 2: Deploy and open the production domain
Deploy as usual, then open the site on its real domain.
data-domainskeeps preview deployments on*.vercel.appout of your numbers, so a preview URL sends nothing until you add its hostname. That is on purpose: previews are not visitors. - 03
Step 3: Add the proxy route to vercel.json
Under Settings, Tracking code, Proxy through your own domain, the dashboard proposes a path for your site. Add a route that forwards it to the collector. The two
deletetransforms, documented in Vercel’s vercel.json reference, remove cookies and authorization before the request leaves Vercel. Vercel processes routes in the order you list them, so put this one before any catch-all route.vercel.json{"routes": [{"src": "/k3x9qe/(.*)","dest": "https:// in. crispstats. com/ p/ $1","transforms": [{ "type": "request.headers", "op": "delete", "target": { "key": "cookie" } },{ "type": "request.headers", "op": "delete", "target": { "key": "authorization" } }]}]} - 04
Step 4: Point the script tag at the path
Replace the tag with this one.
data-apiis required: without it the script sends events to/eon your own domain, and those requests fail.<scriptdeferdata-site="cs_pk_your_site_key"data-domains="example.com"data-api="/k3x9qe"src="/k3x9qe/d.js"></script> - 05
Step 5: Sign the requests (optional)
Reveal the proxy secret (
cs_px_…) under Advanced: sign proxied requests, add it asCRISPSTATS_PROXY_SECRETin the project’s environment variables, add this transform to the route’stransformsand redeploy.{ "type": "request.headers", "op": "set", "target": { "key": "x-crispstats-proxy-secret" }, "args": "$CRISPSTATS_PROXY_SECRET", "env": ["CRISPSTATS_PROXY_SECRET"] }
Check that it works
After deploying, open https://example.com/k3x9qe/check?k=cs_pk_your_site_key with your domain, path and key, in a browser on your own site. Look for "proxied": true, "visitorAddressForwarded": true and "cookiesForwarded": false. "location": { "source": "proxy" } means Vercel’s location headers came through; "timezone" means the country comes from the browser’s timezone instead. Your visit then appears on Realtime.
CrispStats on Vercel
What you get
- Pageviews, visitors, sources and channels for the production domain, with preview deployments left out by
data-domains. - Visitors whose ad blocker stops analytics hosts, counted again once the route is live.
- Visits from AI assistants such as ChatGPT and Perplexity in their own channel, with landing pages and revenue.
- Revenue attribution through the proxy:
crispstats.id()asks/k3x9qe/id, which the same route forwards. - A core script of about 2.2 KB gzipped, cached by browsers for a day and revalidated with a
304.
- Pageviews, visitors, sources and channels for the production domain, with preview deployments left out by
Notes and limits
- Do not proxy with a plain rewrite to another host: it passes every request header on, including your visitors’ login cookies. The transforms in the route are what make it safe.
- If your
vercel.jsonalready hasrewrites,redirectsorheaders, Vercel’s reference saysroutescan sit alongside them, and thatsrcmatching is then case-sensitive. Run the setup check after deploying, and if it fails, forward the path from a server-side function instead. - Vercel adds the visitor’s address to the forwarded request. The collector uses it for the daily visitor hash and your excluded IP addresses, then discards it.
- AI crawlers do not run JavaScript, so they never appear as visitors. Report them from your server or edge code if you want them in the AI crawler report: see AI crawlers.
The docs page covers the optional steps this guide leaves out.
Setup questions. Straight answers.
What people ask before they connect it.
Put the script tag in the head of every page in your code and deploy. Vercel serves it like any other HTML, so there is no Vercel setting or integration to turn on.
The snippet's data-domains attribute lists your real domain, so events from vercel.app preview URLs are not sent. Add a preview hostname to data-domains only if you want those visits counted.
Vercel Web Analytics is Vercel's own product for projects on Vercel. CrispStats works on any host and includes revenue attribution, funnels, error tracking and uptime on every plan. The comparison page has the details.
Not on the CrispStats side: every feature is on every plan and in the 14-day free trial. Vercel's own limits and pricing apply to your project.
Not answered here? Write to hello@crispstats.com
Go further
Related
- CrispStats vs Vercel Analytics
Vercel Web Analytics is built into Vercel and free up to 50k events.
- Next.js analytics
Add CrispStats to a Next.js app with one next/script element in the root layout.
- Revenue attribution
See which source, page and campaign each payment came from.
- First-party data explained
First-party data is data you collect directly from your own visitors and customers.
- Proxy on Netlify
Add CrispStats to a Netlify site in your code or with snippet injection, then serve it from your own domain with one edge function.
- Proxy with a Cloudflare Worker
Serve CrispStats from your own domain with a Cloudflare Worker on one route, so visitors behind ad blockers are counted.
Guides
- Next.js analytics: your options and the App Router gotchas
The ways to add analytics to a Next.js app, from Vercel Web Analytics to GA4 and privacy-first scripts, and the App Router mistakes that skew your numbers.
- Web analytics pricing compared: 36 tools at 10k, 100k and 1M a month
What 36 analytics tools cost at 10k, 100k and 1M a month, from each vendor's pricing page, and why pageviews, events, sessions and users differ.
Other integrations
Hosts
Frameworks
Site builders
Ecommerce platforms
Tag managers
Your traffic, crisp and clear
One script, no cookies, and every feature from the first day. Set up takes about as long as pasting a snippet.