You suspect some of your traffic isn't human. Maybe your analytics look inflated, your forms collect garbage, or your API bills grow without real customers. This guide shows you how to detect bots on your website using signals you already have, then how to make detection automatic.
First: know what you're looking for
Not all bots are bad. A useful taxonomy:
- Good, declared bots: Googlebot, Bingbot, search crawlers you want (they bring customers).
- Good, operational bots: uptime monitors, payment-webhook callbacks.
- Harmful bots: scrapers stealing content, form-spam scripts, credential-stuffing tools, scalpers, vulnerability scanners, and (the newest wave) AI crawlers that don't declare themselves.
Detection isn't "block all bots" — it's knowing which is which and deciding per request.
Seven signs of bot traffic you can check today
- Analytics vs expectations. Sessions with 0:00 duration, 100% bounce, or direct/none sources in unnatural volume.
- Log rhythm. Real visitors pause between requests (seconds). Bots request in machine-perfect intervals or fire parallel bursts.
- User-Agent oddities. Empty UA, ancient browser versions, UA strings claiming Chrome on Linux with Windows-specific headers.
- Header fingerprints. Missing
Accept-Language, header ordering that no real browser produces, HTTP/2 clients announcing HTTP/1.1 traits. - Form behavior. Submissions faster than a human can type, honeypot fields filled, identical timing patterns.
- Known datacenter IPs. Requests from AWS/GCP/Azure ranges when you expect consumers.
- Conversion mismatch. Traffic rises but signups/sales don't — classic scraper signature.
Why User-Agent filtering alone fails
The oldest trick — blocking known-bad user agents — stops only the laziest bots. Any modern scraping library sends a real browser UA string (or a fresh one per request). UA checks are a signal, not a decision. Treat them like a smoke detector that can't tell smoke from steam.
Browser-side signals (what real browsers do)
A real browser executes JavaScript, has a consistent DOM/network stack, and reveals platform details (screen size, timezone, languages) that match its User-Agent. Lightweight browser checks can confirm:
- JavaScript actually executed.
- The environment is consistent (no
WebDriverautomation flag, no headless indicators). - Behavioral velocity looks human (request cadence across 1/10/60-minute windows).
None of these alone is proof — but combined they separate most automation from most humans. That's exactly what XAntiBot's Browser Signals and behavioral velocity do, server-side-assisted.
Automatic detection with an API
The reliable pattern: don't decide in your code — ask a detection API. Your backend sends the visitor's IP + User-Agent + your domain; the API returns a decision with a score and reasons.
With XAntiBot, the decision comes back as allow, challenge, or block:
// PHP example (pattern from the official XAntiBot PHP package)
$ch = curl_init('https://xantibot.com/api/check');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-Key: ' . $apiKey],
CURLOPT_POSTFIELDS => json_encode([
'ip' => $_SERVER['REMOTE_ADDR'],
'ua' => $_SERVER['HTTP_USER_AGENT'] ?? '',
'domain' => 'YOUR_DOMAIN',
]),
]);
$data = json_decode(curl_exec($ch), true);
// Decision: allow → continue; challenge → show challenge flow; block → 403.
(Pattern matches the shipped XAntiBot PHP package; verify against the current docs before production use.)
Why an API beats DIY: IP intelligence (datacenter/TOR lists, ASN data) is maintained for you; scoring logic is updated as bots evolve; and you get logs with reasons — every decision is auditable instead of a mysterious 403.
What to do with the result
allow→ serve normally.challenge→ present a challenge (e.g. Cloudflare Turnstile through a gateway) instead of a silent block — real users pass, most bots fail.block→ 403, quietly.
FAQ
Can I detect bots with 100% accuracy?
No honest tool claims that. The goal is to reliably separate the harmful majority from humans with near-zero false positives.
Do bots hurt SEO?
Bot traffic doesn't directly hurt rankings, but it pollutes analytics, wastes server resources, and scrapers can steal content.
Is User-Agent blocking useless?
No — it's a cheap first filter. Just never make it your only defense.
Next steps
- Start free: create an account and get your first API key.
- Read: How to Block Malicious Bots Without Blocking Real Users and Bot Detection API: Complete Developer Guide.
- PHP site? PHP Bot Protection: Step-by-Step Tutorial.