Field notes, logs
Analytics from nginx logs, without adding a script
Your server already writes down every request. Here is how much of your analytics that log can carry on its own, where it stops, and when a small script is worth adding.
. 5 min read.
You open the Google Analytics dashboard and it says 312 visitors yesterday. Your server says it answered 41,000 requests. Both are true, and neither is the whole story. The second number has been sitting in /var/log/nginx/access.log the entire time, and nobody asked it anything.
This note is about that file: what you can learn from it with no script on your site, where it honestly runs out, and how StatsRaven reads it.
The short answer
Yes, an nginx access log is enough for a useful picture of your traffic, and it needs no script, no cookies and no consent banner. It tells you which pages are requested, what fails, where people come from, which crawlers and AI agents visit, and what changes after a deploy. It does not tell you how long someone stayed, how far they scrolled or which country they are in. For those, a small cookieless script adds what the log cannot see.
What does an nginx access log actually record?
Every line in nginx's default combined format records one request: who asked, when, for what, what the server answered, how big the answer was, which page linked there, and what the client said it was.
203.0.113.24 - - [21/Nov/2026:09:14:02 +0100] "GET /pricing/?ref=nl HTTP/2" 200 5120 "https://news.example.com/" "Mozilla/5.0 (iPhone; ...)"
- Address
- Turned into a daily visitor code, then dropped
- Request
- GET /pricing/, the query string removed
- Status
- 200, so it worked
- Size
- 5,120 bytes
- Referrer
- news.example.com sent them
- User agent
- Safari on an iPhone, or so it claims
That is already most of a traffic report. Group the lines by path and you have your top pages. Group by status and you see your errors. Group by referrer and you see who sends you people.
Two details matter for privacy. The query string can hold login links and other secrets, so StatsRaven removes it before anything is stored. And the address is never kept: StatsRaven turns address and user agent into a short visitor code with a salt that changes every day, so the same browser cannot be followed from one day to the next.
How do you read nginx logs without a tracking script?
You point a reader at the file and let it follow the file as it grows. With StatsRaven that is one command on the server:
statsraven watch --project shop --source nginx --format access /var/log/nginx/access.log
Or add the file in Settings, Projects, and it is picked up within ten seconds without a restart. A few things happen quietly from there:
- Rotation is handled. The file is checked every two seconds. When logrotate moves it, StatsRaven finishes the old file before it starts the new one.
- Nothing is read twice. The read position is saved only after the lines are safely on disk.
- History is your choice. A new follow starts at the end of the file. To load what is already there, follow from the start, or import old files, gzipped ones too, with
statsraven ingest.
The sources guide has every option, including journald and Cloudflare Workers logs.
What can you learn from access logs alone?
More than most people expect, because the log sees every request, not only the ones from browsers that ran a script.
- Pages and routes. IDs, UUIDs and long hex strings in paths are folded, so
/orders/8812and/orders/9104count as one route. Static files such as images, styles and scripts are grouped apart, so they do not crowd your pages. - Errors. Every 5xx is marked as an error. You see which routes fail, since when, and how often.
- Referrers. Who links to you, page by page.
- Who is asking. People, crawlers, AI agents, scanners and API clients, told apart on every request. That deserves its own note.
- Patterns. Request lines are grouped into named patterns, so "failed checkouts" becomes something you can ask about. Words like checkout, billing and signup are never folded away, so money paths stay visible however rare they are. How patterns work.
And then you ask. "Which pages return the most errors?", "Who is hitting my API hardest?", "Which errors are new since last night?" StatsRaven answers in plain language with the chart and the query behind it. Or ask from Claude, over MCP, with no AI key in StatsRaven at all.
What can't server logs tell you?
This is where honesty matters, because a log is a record of requests, not of people.
From the log alone
- Pages and routes
- Errors and status codes
- Referrers
- Crawlers, AI agents, scanners
- API clients
- Named patterns
Needs the snippet
- Visits, bounce rate, visit length
- Time on page and scroll depth
- Navigation inside single-page apps
- UTM campaign tags
- Country, city and device
- Browser language
- Time and attention. A request says a page was fetched, not that anyone read it. Time on page and scroll depth only exist in the browser.
- Visits. StatsRaven counts visitors, visits, bounce and visit length from the browser snippet only, bots excluded. Rebuilding visits from raw requests guesses too much, so it does not try.
- Places and devices. A combined-format line has no country and no clean device type. StatsRaven gets those from Cloudflare's request data or from the snippet, not from a database of addresses.
- Single-page apps. When an app changes pages in the browser, the server never hears about it.
- Speed. The default combined format does not include response time, so slow requests are not visible from it.
Is a script still worth adding?
Here is the strongest case for the script, and it is a good one. If your question is "are people reading this and acting on it?", the log cannot answer. Engagement, campaigns and funnels belong to the browser. A tracking script also sees pages served from a CDN cache that never reach your server.
The case against is just as real. Many sites add a script, then a consent banner, then lose a share of visitors who decline, and end up with numbers that are partly guessed. The log has none of that: it counts every request, and it is already there.
So the useful answer is both, in that order. Start with the log: it costs nothing, needs no change to your site and shows you the traffic your script never sees. Add StatsRaven's cookieless snippet when you want visits and attention. It sets no cookies and stores nothing on the visitor's device, so it needs no banner either. Then compare the two: the scraper check is built on exactly that difference.
What StatsRaven does with this
StatsRaven reads the combined access log from nginx or Apache, journald, Cloudflare Workers logs, JSON events and OpenTelemetry, on your own server, as one binary with no database to install. The log becomes routes, errors, referrers, classified traffic and named patterns. The snippet adds visits and attention. Chat, or Claude over MCP, puts them in one question.
It is free for one project and $49 once for three. See pricing, or start with the quickstart.
Your server has been taking notes all along. Ask it.
Questions
Can I get website analytics from nginx logs alone?
Yes, for pages, errors, referrers, crawlers and the shape of your traffic. Visits, time on page, scroll depth, countries and devices need a browser script or Cloudflare's request data, because a plain access log does not record them.
Which nginx log format does StatsRaven read?
The standard combined format that nginx and Apache write by default, with or without a virtual host prefix. Custom log_format layouts are not parsed today.
Does reading access logs need a cookie banner?
No script runs in the visitor's browser and nothing is stored on their device, so there is nothing to consent to for cookies. StatsRaven also does not store IP addresses: it turns them into a visitor code with a salt that changes every day.
What happens when nginx rotates the log file?
StatsRaven checks the file every two seconds. When it is rotated, it first finishes reading the old file, then starts the new one from the top, so no lines are lost.
Can I import old log files?
Yes. Stop the server and run statsraven ingest with the old files, gzipped ones included. A followed file starts at its end unless you ask it to read from the start.
Should I still add the browser snippet?
Add it if you want visits, time on page, scroll depth, places and devices. Keep the logs too: they see the crawlers, scanners and API calls that never run a script.