Why User-Agent Detection Matters
As AI browsers like ChatGPT Atlas, Perplexity, and Claude become mainstream, publishers need reliable ways to detect this traffic. User-Agent strings are the primary method.
Understanding User-Agent Strings
Every browser sends a User-Agent string with each HTTP request, identifying itself to the web server:
// Traditional browser (Chrome)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/120.0.0.0 Safari/537.36
// AI Browser (ChatGPT Atlas)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko)
ChatGPT-Atlas/1.0 Chrome/120.0.0.0 Safari/537.36
AI Browser User-Agent Patterns
1. ChatGPT Atlas
Pattern: ChatGPT-Atlas
ChatGPT-Atlas/1.0
Detection logic:
function isAtlas(userAgent) {
return /ChatGPT-Atlas/i.test(userAgent);
}
2. Perplexity Browser
Pattern: Perplexity
Perplexity/2.0 Safari/605.1.15
Detection logic:
function isPerplexity(userAgent) {
return /Perplexity//i.test(userAgent);
}
3. Claude Browser
Pattern: Claude-Browser
Claude-Browser/1.0 AppleWebKit/537.36
4. Google AI (Gemini/Bard)
Pattern: Google-AI or Gemini
Google-AI/1.0 (Gemini)
5. Bing Copilot
Pattern: Copilot
Mozilla/5.0... Copilot/1.0...
Complete Detection Function
Here's a comprehensive function to detect all major AI browsers:
function detectAIBrowser(userAgent) {
const patterns = {
atlas: /ChatGPT-Atlas/i,
perplexity: /Perplexity//i,
claude: /Claude-Browser/i,
gemini: /Google-AI|Gemini/i,
copilot: /Copilot//i,
};
for (const [browser, pattern] of Object.entries(patterns)) {
if (pattern.test(userAgent)) {
return {
isAI: true,
browser: browser,
confidence: 0.95
};
}
}
return {
isAI: false,
browser: 'unknown',
confidence: 0
};
}
Server-Side Detection
Node.js / Express
app.get('/', (req, res) => {
const userAgent = req.headers['user-agent'];
const detection = detectAIBrowser(userAgent);
if (detection.isAI && detection.browser === 'atlas') {
// Serve AI-optimized content
res.render('ai-optimized', { browser: 'atlas' });
} else {
// Serve standard content
res.render('standard');
}
});
Cloudflare Workers
export default {
async fetch(request) {
const userAgent = request.headers.get('user-agent');
const isAtlas = /ChatGPT-Atlas/i.test(userAgent);
if (isAtlas) {
return new Response('Atlas-optimized content', {
headers: { 'Content-Type': 'text/html' }
});
}
return fetch(request);
}
}
Client-Side Detection
Detect AI browsers in JavaScript:
// In the browser
const userAgent = navigator.userAgent;
const isAtlas = /ChatGPT-Atlas/i.test(userAgent);
if (isAtlas) {
console.log('Atlas browser detected!');
// Initialize Atlas-specific features
}
Best Practices
1. Use Regular Expressions
User-Agent strings can vary. Use flexible regex patterns:
// ✅ Good (flexible)
/ChatGPT-Atlas/i
// ❌ Bad (too strict)
userAgent === 'ChatGPT-Atlas/1.0'
2. Cache Detection Results
Don't detect on every request. Cache for the session:
// Store in localStorage
localStorage.setItem('isAtlas', 'true');
// Or session variable (server-side)
req.session.isAtlas = true;
3. Combine with Other Signals
User-Agent alone isn't foolproof. Combine with:
- Referrer headers
- Behavioral analysis
- API headers (when available)
Common Pitfalls
1. Spoofing
User-Agents can be spoofed. Always validate with secondary signals.
2. Version Changes
AI browsers update frequently. Use flexible patterns that don't depend on specific versions.
3. Mobile vs Desktop
AI browsers may have different User-Agents on mobile:
// Desktop
ChatGPT-Atlas/1.0 ... Macintosh
// Mobile (hypothetical)
ChatGPT-Atlas/1.0 ... iPhone
Using Panxo for Detection
Rather than building detection yourself, Panxo handles this automatically:
<script async
src="https://cdn.panxo.ai/o/{your-unique-hash}">
</script>
Panxo automatically:
- Detects ChatGPT Atlas and other AI browsers
- Provides confidence scoring
- Updates patterns as browsers evolve
- Handles edge cases and mobile variants
Skip the Implementation Headaches
Let Panxo handle AI browser detection while you focus on content.
Get Started Free