@siteline/nextjs package to track AI bot visits on your Next.js site. The tracker runs in a fire-and-forget pattern inside Next.js proxy code — requests are not awaited, so there is zero impact on page load times.
Prerequisites
- A Siteline website key
- A Next.js project using the App Router or Pages Router
Setup
How it works
The package hooks into Next.js proxy, which runs on every matched request before the page renders:- A visitor (or AI bot) makes a request to your Next.js site
- The proxy extracts bot-relevant metadata (URL, user agent, IP, referrer)
- Tracking data is sent to Siteline asynchronously — the request is not awaited
- The page response is returned to the visitor unmodified
_next/static, _next/image, favicon.ico) are excluded via the route matcher.
Custom Proxy Logic
If you already have proxy logic, pass it as the second argument towithSiteline:
proxy.ts
Configuration
Your Siteline website key. Found under Agent Analytics > Manage Configuration in your Siteline workspace. You can pass it directly or set it with the
SITELINE_WEBSITE_KEY environment variable.Custom Siteline intake endpoint. Most sites can omit this.
Enables debug logging. Use this only while developing or troubleshooting.
Next.js route matcher config. The example pattern excludes API routes and static assets. Adjust to
match the routes you want to track.
Troubleshooting
Proxy not tracking visits
Proxy not tracking visits
Ensure
proxy.ts is in the root of your project (next to package.json), not inside src/ or
app/. Next.js picks up proxy files from the project root.Where do I find my website key?
Where do I find my website key?
Navigate to Agent Analytics in your Siteline workspace and click Manage Configuration to
view or regenerate your key.
I already have proxy logic — will this conflict?
I already have proxy logic — will this conflict?
No. Pass your existing logic as the second argument to
withSiteline. It runs asynchronously
and returns your response unchanged.Will this slow down my site?
Will this slow down my site?
No. The tracking call is fire-and-forget — it is not awaited and never blocks the response. All
errors are silently caught.