d3creative / statamic-headcount
Headcount by D3 Creative - Bots vs Humans for Statamic. Shows how much of a site's traffic is real people and how much is bots, which bots they are, and what the AI crawlers read.
Package info
github.com/d3creativeuk/statamic-headcount
Type:statamic-addon
pkg:composer/d3creative/statamic-headcount
Requires
- php: ^8.3
- statamic/cms: ^6.0
Requires (Dev)
- orchestra/testbench: ^10.8 || ^11.0
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Headcount for Statamic. See how much of your site's traffic is real people and how much is bots, which bots they are, and which pages the AI crawlers read.
Analytics tools like Google Analytics, Plausible and Fathom count visitors whose browser runs their JavaScript, and they filter out the bots they recognise. That makes them good at counting people. It also means they can't tell you how much of your traffic isn't people at all: search engines, AI crawlers, SEO tools, uptime monitors, link previews, scripts and vulnerability scanners.
Headcount counts every request on the server and sorts it:
- Humans and bots, side by side. The share of page requests from humans, suspected bots and named bots, per day and in total.
- Every bot by name. Googlebot, GPTBot, ClaudeBot, PerplexityBot, Meta's AI crawler, AhrefsBot, UptimeRobot and more than 100 others, grouped by type.
- What the AI crawlers read. The pages AI crawlers and assistants request most, which are the pages most likely to shape what AI tools say about you.
- Fake bots caught. Google, Bing, Apple, OpenAI and Perplexity publish the IP ranges their bots use. A "Googlebot" from anywhere else is counted as a fake.
- Suspected bots. Clients that send a browser's user agent but don't behave like a browser are counted separately from people.
Everything stays on your server. No IP addresses or cookies are stored. See Privacy.
Requirements
- Statamic 6 and PHP 8.3+
- Laravel's scheduler running (
* * * * * php artisan schedule:run), which most Statamic hosts already have
Installation
composer require d3creative/statamic-headcount
That's all for the default setup. Requests are recorded from the next page load, counted every five minutes by the scheduler, and shown under Tools → Utilities → Headcount in the Control Panel.
The report has five tabs:
- Overview. The split between humans, suspected bots and bots, and a chart of page requests per day. Filter the chart by type of traffic or by bot: search for "AI crawlers" or "GPTBot", or pick from the list.
- Traffic. Each type of traffic, with its share and the paths it asked for most.
- Top pages. What AI crawlers read and what humans read, side by side.
- Bots. Every bot by name, with its operator and whether it was verified.
- Missing pages. Paths bots asked for that don't exist, with suggested NGINX rules. See below.
Hover over a segment of the chart or the share bar to see its count.
The utility and the widget follow the Control Panel into dark mode, using its own theme colours, so a custom Control Panel theme carries through.
The hover numbers and dark mode come from a small stylesheet, which Statamic publishes when it runs statamic:install after Composer. If they don't appear, for example because your deploy runs Composer without its scripts, publish it yourself:
php artisan vendor:publish --tag=statamic-headcount --force
Super admins see the utility straight away. To give a role access, tick Headcount under Utilities in the role's permissions.
To change any setting, publish the config file:
php artisan vendor:publish --tag=headcount-config
Dashboard widget
Add the widget to config/statamic/cp.php:
'widgets' => [ ['type' => 'headcount', 'width' => 50], ],
It shows the last 7 days. Add 'days' => 30 to change that. It only appears for users who can see the utility.
Choosing where requests come from
There are two sources. The default works everywhere. The access log is more complete if you can give PHP access to it.
| Middleware (default) | Access log | |
|---|---|---|
| Setup | None | Point it at your NGINX or Apache log |
| Works on shared hosting | Yes | Only if PHP can read the log |
| Sees pages served by Statamic | Yes, including the "half" static cache | Yes |
| Sees pages served by the "full" static cache | No | Yes |
| Sees CSS, JavaScript and images | No | Yes |
| Sees requests your web server blocks | No | Yes |
| How it spots a real browser | The headers every current browser sends | The browser fetching the page's CSS, JavaScript and images |
Middleware
Headcount adds a middleware to Laravel's web group. It records each request after the response has been sent, so pages don't wait for it, and appends one line to a buffer file. The scheduler counts the buffer every five minutes, and opening the utility counts what's waiting if it's under 2MB, so the report is current. More than that is left to the scheduler. If the scheduler stops, recording pauses at 20MB rather than filling the disk, and the utility tells you.
If your site uses Statamic's full static caching, your web server answers most pages without running PHP, so the middleware can't see them. The utility warns you about this. Use the access log instead.
Access log
Set the source and the path to your site's access log in .env:
HEADCOUNT_SOURCE=log HEADCOUNT_LOG_PATHS=/var/log/nginx/example.com/access.log
Separate several logs with commas. The log must use the standard combined format, which NGINX and Apache both write by default (NGINX's main format works too).
The scheduler reads new lines every ten minutes and remembers where it stopped. When logrotate moves the log aside, it finishes the old file (access.log.1) before starting the new one.
PHP needs to be able to read the log. On most servers the log belongs to root and the adm group, and PHP runs as another user (ploi, forge or www-data), so it can't. Avoid adding the PHP user to adm: that group can also read your server's authentication logs. Instead, give the site its own log that the PHP user's group can read. For NGINX, in your site's server block:
access_log /var/log/nginx/example.com/access.log combined;
Then create the folder, and a logrotate rule that recreates the file with that group (replace ploi with your PHP user, and nginx with www-data on Debian's own NGINX package):
sudo mkdir -p /var/log/nginx/example.com sudo chgrp ploi /var/log/nginx/example.com sudo chmod 750 /var/log/nginx/example.com
# /etc/logrotate.d/example.com
/var/log/nginx/example.com/*.log {
daily
rotate 30
compress
delaycompress
missingok
notifempty
create 0640 nginx ploi
sharedscripts
postrotate
[ -f /run/nginx.pid ] && kill -USR1 `cat /run/nginx.pid`
endscript
}
Reload NGINX (sudo nginx -t && sudo systemctl reload nginx). If PHP can't read the log, the utility tells you so.
If you'd rather not change permissions at all, a root cron job can copy the log somewhere PHP can read once a day, and you can import each copy with the headcount:import command below.
Importing older logs
To include logs from before you installed the addon, pass them to the import command. .gz files are read directly. Each file is remembered, so importing it twice doesn't double the figures.
php artisan headcount:import /var/log/nginx/example.com/access.log.2.gz /var/log/nginx/example.com/access.log.3.gz
Don't import files the scheduler has read or will read. The current log and access.log.1 are read automatically.
How traffic is sorted
Each request is checked in this order:
- A bot Headcount knows. Matched on the user agent against a list of more than 100 bots. If its operator publishes IP ranges and the request came from outside them, it's a fake.
- A probe. Requests for files a Statamic site doesn't have, such as
/.env,/wp-login.phpor/phpmyadmin, are vulnerability scanners, whatever they claim to be. - A bot it doesn't know. A user agent that says it's a bot ("bot", "crawler", a URL) is listed by the name it gives.
- A browser. A browser's user agent counts as a person once that visitor has shown a real browser's signs that day. Otherwise it's a suspected bot.
- Anything else is counted with other bots.
| Type | What it covers |
|---|---|
| Humans | Real browsers that behaved like one |
| Suspected bots | Sent a browser's user agent but showed none of a browser's signs |
| Search engines | Googlebot, Bingbot, Applebot, DuckDuckBot, YandexBot and others |
| AI crawlers | GPTBot, ChatGPT-User, ClaudeBot, PerplexityBot, Meta's AI crawler, Amazonbot, Bytespider, CCBot and others |
| SEO tools | Ahrefs, Semrush, Majestic, Moz, Screaming Frog and others |
| Link previews | Fetched when someone shares a link on LinkedIn, X, Bluesky, Slack, WhatsApp and others |
| Uptime monitors | UptimeRobot, Pingdom, Oh Dear, Better Stack and others |
| Testing tools | Lighthouse, GTmetrix, validators and headless browsers |
| Scripts | curl, Python, Go and other HTTP libraries, or no user agent at all |
| Vulnerability scanners | Probes for files and admin pages, and scanners that name themselves |
| Fake bots | Claimed to be a verifiable bot from outside its published IP ranges |
| Other bots | Said they were a bot, but aren't on the list |
Shares are of page requests: everything except CSS, JavaScript, fonts, images, media and PDFs. That's what most people mean by traffic.
Checking bots are who they say they are
Once a week the scheduler downloads the IP range lists that Google, Bing, Apple, OpenAI (GPTBot, OAI-SearchBot and ChatGPT-User) and Perplexity publish. Requests are checked against the stored copy, so a slow download never holds up a page. The Checked column in the utility shows whether each bot was verified. Bots whose operators don't publish ranges, such as ClaudeBot, are named by user agent only.
To download the lists straight away, run php artisan headcount:ranges. To switch checking off, set HEADCOUNT_VERIFY=false.
Missing pages and NGINX rules
Vulnerability scanners ask for thousands of paths your site doesn't have: /wp-login.php, /.env, /.git/config, /phpmyadmin. Each one boots PHP and Statamic just to return a 404. The utility's Missing pages tab lists the paths that returned 404 or 410 to anything that wasn't a person, and turns them into NGINX rules that answer them before PHP runs.
Requests your web server already blocks never reach Headcount, so the list is exactly what's still getting through. Add a rule, and those paths stop appearing.
The suggestions come in three kinds, in the same shape as a hand-written blocklist:
# /.git (114), /config (94), /.aws (92), /phpmyadmin (91) location ~* ^/(\.git|config|\.aws|phpmyadmin)([/.]|$) { access_log off; log_not_found off; return 444; } # Backup, config and secret files: .sql (101), .env (87) location ~* \.(sql|env)$ { access_log off; log_not_found off; return 444; } # PHP and other script files (473 requests). Statamic only runs PHP through # /index.php, which the lookahead leaves alone. location ~* ^/(?!index\.php$).+\.(php\d?|phtml|phar|asp|aspx|jsp|cgi)$ { access_log off; log_not_found off; return 444; }
return 444 closes the connection without sending anything, and access_log off keeps the blocked noise out of your log.
To keep the rules from blocking real pages:
- Paths your site uses are left alone. A path isn't suggested if its first part belongs to one of your sites' addresses (such as
/fron a multisite install), an entry, a taxonomy term, an asset container, a Laravel route, a file inpublic/, or Statamic itself (/cp,/!/,/img,/vendor). A missing page under a real section, such as/blog/an-old-post, is flagged as a possible old URL that may want a redirect instead. - Only file types a Statamic site never serves get a file-type rule, and only if yours doesn't serve them either: a
.yamlfile inpublic/or a.keyfile in an asset container keeps that type out of the rules. Archives such as.zipare left out, because they can be real downloads. - Each rule needs at least 3 requests, so a one-off typo doesn't become a rule.
- No rules if the check can't run. If your entries, terms or files can't be loaded, the missing pages are still listed but no rule is suggested, and the error goes to your Laravel log.
Review every line before you use it. A first-part rule blocks the whole path, and a page you create later could share it. Add the rules to your site's server block above the PHP location, then run sudo nginx -t && sudo systemctl reload nginx. On Ploi or Forge, add them through the site's NGINX configuration so they aren't overwritten.
php artisan headcount:nginx-rules --days=30 prints the same rules in the terminal.
The rules are for NGINX. On Apache, the list still shows what's worth blocking, but you'll need to write the rules yourself.
Commands
| Command | What it does |
|---|---|
headcount:report --days=7 |
Shows the split and the top bots in the terminal |
headcount:aggregate |
Counts what the middleware has recorded (every five minutes by the scheduler) |
headcount:import |
Reads new lines from the configured logs (every ten minutes when the source is log) |
headcount:import <files> |
Imports whole log files once, such as older rotated logs |
headcount:ranges |
Downloads the published bot IP ranges (weekly) |
headcount:nginx-rules --days=30 --min=3 |
Suggests NGINX rules for paths bots asked for that don't exist, leaving out anything requested fewer than --min times |
headcount:prune |
Deletes days older than the retention period (nightly) |
Configuration
These cover most needs. The config file explains every option.
.env setting |
Default | |
|---|---|---|
HEADCOUNT_ENABLED |
true |
false stops recording. The Control Panel still shows what was recorded |
HEADCOUNT_SOURCE |
middleware |
middleware or log |
HEADCOUNT_LOG_PATHS |
Comma-separated access log paths, for the log source |
|
HEADCOUNT_LOG_SCHEDULE |
*/10 * * * * |
How often the logs are read |
HEADCOUNT_RETENTION_DAYS |
90 |
Days of totals to keep |
HEADCOUNT_EXCLUDE_IPS |
Comma-separated IPs or ranges to leave out, such as your office | |
HEADCOUNT_VERIFY |
true |
Check bots against their operators' published IP ranges |
HEADCOUNT_BRANDING |
true |
Show "by D3 Creative" in the utility's footer |
The Control Panel is always left out. In the config file you can also leave out paths and user agents, change the probe patterns, and change the limits.
Privacy
- No IP addresses are stored. A visitor is a hash of IP address and user agent, keyed with your app key and the date. The same visitor gets a new, unrelated hash every day, so visits can't be linked across days. IP addresses are only used in memory, to make that hash and to check a claimed bot against its operator's ranges.
- No cookies and no JavaScript. Nothing is added to your pages.
- No query strings. Paths are stored without them, because they can hold email addresses or tokens.
- Everything stays on your server, under
storage/app/headcount, as daily totals. The list of visitor hashes is deleted by the nightly clean-up, within two days of each day ending. Days older than the retention period (90 by default) are deleted. - The only outbound requests are the weekly downloads of the IP range lists from Google, Bing, Apple, OpenAI and Perplexity. They send nothing about your site. Set
HEADCOUNT_VERIFY=falseto make none. Nothing is ever sent to D3 Creative.
If you use the access log source, your web server's own logs contain IP addresses anyway. Your privacy policy should already say how long you keep them.
Limitations
The figures are a good estimate, not an exact count.
- Bots that use a real browser (headless Chrome with its user agent changed) fetch assets and send browser headers like a person, so they can count as people.
- Suspected bots include some people. A privacy browser or extension that strips headers, or a visitor who leaves before the page's CSS loads, can be counted as a suspected bot.
- A CDN in front of your site, such as Cloudflare with page caching, answers requests before they reach your server. Neither source sees those.
- Visitors are counted per day, like Plausible. The visitor figure in the utility is daily unique visitors added up, not unique visitors over the period.
- Multisite. Every site's traffic is added together in one report. There's no split by site.
- Very busy sites. Each day keeps the top 300 paths per type of traffic and up to 50,000 visitor hashes. Beyond those, counts are still added up but not broken down.
Support
Headcount is maintained by D3 Creative. Report bugs or ask questions in GitHub issues. Report security problems privately instead. See the security policy. For managed Statamic maintenance, visit d3creative.uk/services/statamic-maintenance.
License
MIT. See LICENSE.

