The Salespeak LLM Analytics for Vercel integration automatically detects AI agents (such as ChatGPT, Claude, Perplexity, BingPreview, and others) and tracks LLM traffic to your website.
The integration uses Next.js Middleware and an Edge Route Handler to route AI agent traffic through a proxy that can log analytics events and inject AI-optimized content when available.
Regular visitors continue to see your website normally with no changes to the user experience.
Deployment Guide
For the full implementation reference, see the official deployment guide:
https://github.com/salespeak-ai/nextjs-boilerplate/blob/main/DEPLOYMENT.md
Summary of Steps
Clone the Salespeak Next.js boilerplate
Add the middleware and proxy route files
Configure your Salespeak organization ID
Deploy your project to Vercel
Test the integration
1. Clone the Next.js Boilerplate
Start with the Salespeak boilerplate repository:
https://github.com/salespeak-ai/nextjs-boilerplate
This repository includes the required integration files:
• middleware.ts
• app/api/ai-proxy/route.ts
You can either:
• clone the repository and build from it
or
• copy the required files into your existing Next.js project.
2. Add the Salespeak Integration Files
The integration requires two files.
middleware.ts
Place this file in the root of your Next.js project.
The middleware inspects the request User-Agent and determines whether the visitor is an AI agent.
If the request matches an AI crawler, the request is rewritten to the Salespeak proxy route.
Example path:
/middleware.ts
AI Proxy Route
Create the following route handler:
/app/api/ai-proxy/route.ts
This Edge route:
• logs AI traffic to Salespeak
• fetches the original page
• fetches AI-optimized content from the alternate origin
• injects optimized content when available
The route runs using the Vercel Edge runtime.
3. Configure Your Organization ID
Open the middleware.ts file and replace the placeholder organization ID with your Salespeak organization ID.
Example:
const ORGANIZATION_ID = "your-salespeak-organization-id";
This ID allows Salespeak to associate AI traffic with your account.
4. Deploy to Vercel
Once the files are added and configured:
Commit the changes to your repository.
Push the changes to your deployment branch.
Vercel will automatically build and deploy your application.
You can also deploy using the Vercel CLI if preferred.
No additional configuration is required because the proxy route uses the Edge runtime by default.
5. Supported AI Agents
The middleware detects the following AI user agents:
• ChatGPT-User
• BingPreview
• PerplexityBot
• Claude-User
• Claude-Web
• ClaudeBot
When these agents are detected, traffic is routed through the Salespeak proxy.
6. Caching Behavior
AI responses are not cached.
The proxy returns headers similar to:
Cache-Control: private, no-store, max-age=0
Vary: User-Agent
This ensures:
• AI crawlers receive fresh optimized responses
• human visitors continue using normal site caching.
7. Fallback Behavior
If optimized AI content is not available:
• the system automatically returns the original page
This guarantees that your site always loads normally even if the proxy cannot fetch alternate content.
8. Test the Integration
After deployment:
Confirm the site deploys successfully on Vercel.
Verify the
ORGANIZATION_IDis correctly configured.Send a request using an AI user agent.
Confirm the request routes through
/api/ai-proxy.Verify the response contains the header:
Vary: User-Agent
Your site should continue functioning normally for standard visitors.
Removing the Integration
To remove the integration:
Delete the following files:
middleware.ts
app/api/ai-proxy/route.ts
Redeploy your application.
Traffic will immediately return to the standard site flow.