Why Use Vercel Log Drains?
Traditional analytics tools rely on JavaScript that runs in the browser. AI crawlers don’t execute JavaScript, so they’re invisible to tools like Google Analytics. Vercel Log Drains capture server-side logs from your Edge Functions, Serverless Functions, and static files, giving you complete visibility into how AI platforms discover and index your content.Benefits
- Capture AI crawler traffic that JavaScript-based analytics miss
- Zero code changes - Configure entirely through the Vercel dashboard
- Real-time logging - Logs are streamed as requests happen
- Works with any Vercel project - Next.js, static sites, or any other framework
Prerequisites
Before you begin, you’ll need:- A Vercel account on the Pro or Enterprise plan
- A deployed project on Vercel
- A ChatFeatured account with Agent Analytics enabled
Setup Instructions
Step 1: Get Your API Key
- Log in to ChatFeatured and navigate to your brand
- Go to Agent Analytics > Settings
- Click Create API Key and give it a name (e.g., “Vercel Log Drain”)
- Copy the generated API key - you’ll need it in Step 9
Step 2: Go to Vercel Dashboard
Navigate to https://vercel.com/dashboardStep 3: Open Team Settings
Click on your team name in the top-left corner → Select SettingsStep 4: Navigate to Drains
In the left sidebar, click DrainsStep 5: Add a New Drain
Click the Add Drain buttonStep 6: Select Data Type
Choose Logs from the available optionsStep 7: Configure Basic Settings
- Name:
Agent Analytics - Projects: Select the projects you want to monitor
You can configure the drain for all projects or select specific ones. Start with your production projects.
Step 8: Configure Log Sources
Expand “Additional configuration for logs”:- Sources: Check the following options:
- Static Files
- Edge Functions
- Functions
- Environments: Check
Production - Sampling: Leave at
100%
These sources include HTTP request data with user agents, which is required for AI bot identification. Don’t modify sampling unless you have very high traffic.
Step 9: Configure Destination
Select the Custom Endpoint tab and configure:| Field | Value |
|---|---|
| Endpoint URL | https://ingest.chatfeatured.com/v1/logs/vercel |
| Format | NDJSON |
| Custom Headers | X-API-Key: YOUR_API_KEY |
YOUR_API_KEY with the API key from Step 1.
Format Explanation: NDJSON (newline-delimited JSON) is a streaming format that sends one JSON object per line. This is optimal for log streaming.
Step 10: Test and Create
- Click Test to verify the connection returns a 200 response
- Click Create Drain
Step 11: Verify Setup
Once configured, AI crawler traffic will appear in your Agent Analytics dashboard within a few minutes. Visit your site to generate some traffic, then check your dashboard for incoming data.How It Works
Vercel Log Drains stream logs from your deployment:- Request arrives at Vercel’s edge
- Vercel processes the request through your application
- Logs are generated containing request metadata (URL, user agent, IP, etc.)
- Logs are streamed to ChatFeatured’s ingestion endpoint in real-time (NDJSON format)
- AI crawlers identified and displayed in your analytics dashboard
What Gets Tracked
The Log Drain captures the following data for each request:- Host - The domain being accessed
- Path - The URL path being requested
- User Agent - Used to identify AI crawlers
- IP Address - For geographic insights
- Status Code - The HTTP response status
- Timestamp - When the request occurred
- Request Method - GET, POST, etc.
Advanced Configuration
Filtering Projects
You can configure the Log Drain to only track specific projects:- When creating or editing the drain, select specific projects instead of “All Projects”
- This is useful if you only want to track production marketing sites, not development projects
- You can create multiple drains with different project filters
Multi-Environment Tracking
To track multiple environments:- Create separate drains for each environment (Production, Preview, Development)
- Use different drain names to distinguish them (e.g., “Agent Analytics - Production”)
- Filter by environment in each drain configuration
Custom Endpoint Headers
If you need to pass additional headers:- In the Custom Headers field, you can add multiple headers separated by newlines
- Format:
Header-Name: value - Example:
Troubleshooting
No data appearing in dashboard
No data appearing in dashboard
- Verify the drain is active - Check the Drains page in Vercel settings
- Check the API key - Ensure the
X-API-Keyheader is set correctly - Test the connection - Use the Test button in the drain settings
- Check log sources - Ensure Static Files, Edge Functions, and Functions are selected
- Verify Production environment - Make sure Production is selected in log sources
Test returns an error or 401 Unauthorized
Test returns an error or 401 Unauthorized
Some requests not appearing in analytics
Some requests not appearing in analytics
- Ensure Production environment is selected
- Check that sampling is set to 100% (reducing sampling will skip logs)
- Verify that the relevant log sources are checked (Static Files, Edge Functions, Functions)
- Wait 2-3 minutes for logs to process and appear in the dashboard
Drain shows 'Inactive' or 'Error' status
Drain shows 'Inactive' or 'Error' status
- Click on the drain to view error details
- Re-test the connection using the Test button
- Verify your endpoint URL and API key haven’t changed
- If the error persists, try removing and recreating the drain
High log volume or performance impact
High log volume or performance impact
- Verify that NDJSON format is being used (not JSON, which is less efficient)
- Reduce sampling rate if you have extremely high traffic (note: this will lose data)
- Filter to specific projects if you don’t need all projects tracked
- Contact Vercel support if you’re experiencing performance issues
API Key has expired or been rotated
API Key has expired or been rotated
- Generate a new API key in ChatFeatured
- Go to your Vercel Log Drain settings
- Update the
X-API-Keyheader with the new key - Click Test to verify the connection
- Save the changes
Best Practices
Setup & Configuration
- Use dedicated API keys for each integration
- Test the connection before finalizing setup
- Start with production projects before adding non-production
- Monitor your Vercel dashboard for drain status
Monitoring & Maintenance
- Regularly check your Agent Analytics dashboard for data flow
- Rotate API keys periodically from ChatFeatured settings
- Archive old data if you need to free up quota
Optimization
- Use project filtering if you have many Vercel projects
- Keep sampling at 100% for accurate bot tracking
- Review log sources to match your tracking needs
Performance Notes
Setup Latency:- No impact on your site performance (drains don’t block requests)
- Log delivery to ChatFeatured happens asynchronously
- Real-time streaming (logs appear in ChatFeatured within seconds)
- NDJSON format optimizes for throughput
- Can handle high-volume production sites
- Scales automatically with your Vercel plan
Security & Best Practices
API Key Management
- Create a dedicated API key for Vercel (don’t reuse keys)
- Rotate keys periodically from the ChatFeatured dashboard
- Revoke keys immediately if you suspect compromise
- Never commit keys to version control or public repositories
Data Privacy
- Only request metadata is logged (no page content or user data)
- IP addresses are used for geographic aggregation only
- All data is transmitted over HTTPS
- ChatFeatured is GDPR compliant
Pricing
Vercel Log Drains availability by plan:| Plan | Log Drains |
|---|---|
| Hobby | Not available |
| Pro | Included |
| Enterprise | Included |
Next Steps
Once your Vercel integration is set up:- Monitor your dashboard - Check Agent Analytics to see AI crawler activity
- Track citations - See which pages AI models cite in their responses
- Optimize content - Use insights to improve AI visibility for high-traffic pages
- Correlate with performance - Compare AI traffic patterns with your site metrics
See Also
- Cloudflare Integration — Alternative for non-Vercel hosting
- Agent Analytics — Understanding your data