Install
Install with a Vercel log drain
For sites on Vercel where you'd rather not add a file to the project: a log drain sends Vercel's request logs to Punchline, and each page request becomes the same event the middleware or the Next.js package would have sent. No code, no deploy.
- Nothing runs in your project. Vercel posts its logs to Punchline after the fact; your functions and pages are untouched.
- It sees what Google Analytics can't: crawlers, AI fetchers and coding agents that never run JavaScript.
- Vercel Pro or Enterprise. Drains aren't available on Hobby. Vercel bills drains by volume.
Use one server-side install per site: a drain and the middleware together would count every page twice. The browser snippet can be added to either.
Set it up
You'll need your PUNCHLINE_DSN value (Site settings → Install in your dashboard). It looks like https://<site-id>:<secret>@app.punchlineanalytics.com/api/collect; you'll use the two parts.
- In Vercel, open your team settings → Drains → Add drain (or the project's Settings → Drains).
- Type: Logs. Format: JSON or NDJSON, either works. Environment: Production. Sources: keep the request sources (Function/Lambda, Edge, Static, Redirect). Build and Firewall lines are ignored if included.
- Endpoint:
https://app.punchlineanalytics.com/api/drains/vercel?site=<site-id>, with the site id from your DSN. - Custom headers: add one line,
Authorization: Bearer <secret>, with the secret from your DSN. This is how the drain authenticates; the endpoint refuses anything else. - Save. Vercel tests the endpoint with a sample delivery; the response is
{"ok":true,"received":…,"counted":0}for a test batch. - Check it's working. Visit a few pages. They appear in your Punchline dashboard within a minute or two of Vercel delivering the batch; Doctor → Site check shows the last page view.
What's counted
Page requests in Production: GET and HEAD for pages and the text files agents fetch (robots.txt, llms.txt, sitemap.xml, *.md). Not counted: assets (images, scripts, styles, fonts), /api/ routes, Next.js internals, client-side navigations (_rsc requests), preview deployments, blocked (firewall) requests, and background revalidations.
Each page request carries what the log has: the path, utm_* values and the query string with credential and personal-data values redacted, the referrer's host, the status and response size, and the visitor's address and user agent, which the collector uses in memory for people and keeps with the visit for agents. The request's own time is kept, not the delivery time.
What a drain can't do
Logs don't carry request headers beyond the user agent and referrer, so compared with an edge install:
- No Web Bot Auth. Signed agents (ChatGPT's agent and others) are still recognized by name and address, but at declared confidence rather than verified.
- No browser-header check. Rule R15 (a browser's name without the headers browsers always send) is skipped.
- No markdown, no share links. The install can't change the response, so serving agents markdown and handoff links minted at the edge need the middleware or the package.
- Later. Vercel delivers batches after the fact, so Realtime lags by a minute or two.
- A batch is stored once. If one request in a batch fails to store, it's logged and counted as failed in the response; Vercel isn't asked to resend, because a resend would store the rest of the batch twice.
If any of those matter, the middleware is one file.
Troubleshooting
- The drain shows errors. Open a failed delivery: a
401means theAuthorizationheader is missing or the secret is wrong; a400means thesiteparameter isn't a site id. Rotating the edge secret in Site settings invalidates the header until you update it. - Nothing arrives, deliveries succeed. The response's
countedsays how many page requests the batch held. Zero on real traffic usually means the drain's environment is Preview, or only Build logs are selected.
Ask the docs
Answers come from these docs only, written by Claude (Anthropic). Your question is sent to answer it, and isn't stored.