Try it on your own data
Every report in this article is in the free plan. One snippet for web and apps, up to 10 sites.
Start freeWeb server analytics measures a site from the access log the server writes. Logs see every request, including bots and status codes, but not what a person did on the page; a tracking script sees people but misses crawlers that never run JavaScript. Use logs for the server and crawlers, and a script for visitors.
What you will learn
- Counting all log lines overstates traffic 4.7 times in the sample: 10,000 lines, 3,900 page requests, 2,320 likely human page views
- Logs and script differed by 170 page views (7.3%) in the sample; a gap of a few percent is normal, 30% is a problem
- A CDN cache can hide visits from the origin log: with 38% served from cache, the origin sees 62% of page requests
What is web server analytics?
Web server analytics means measuring a website from the access log that the web server writes, instead of from a script that runs in the visitor's browser. Every time the server answers a request, it appends one line to the log. Count and group those lines and you have traffic numbers without adding any code to your pages.
A tracking script works the other way round. It runs inside the browser, after the page has loaded, and sends a message to an analytics service. The two methods look at the same visits from different places, so they disagree, and the disagreement is predictable. This article lists what each one can and cannot see, then reconciles them with one worked example.
What is in a server log line?
The Apache documentation describes the access log as recording all requests processed by the server. The widely used Combined Log Format has nine fields; Nginx's predefined combined format uses the same layout and is what access_log falls back to when no format is given.
| Field | Meaning | Apache / Nginx name |
|---|---|---|
| Client address | The IP address that connected (may be a proxy, not the person) | %h / $remote_addr |
| Identity and user | Two fields, almost always - | %l %u / $remote_user |
| Time | When the request was received | %t / $time_local |
| Request line | Method, path and protocol, for example GET /pricing HTTP/1.1 | %r / $request |
| Status code | 2xx success, 3xx redirect, 4xx client error, 5xx server error | %>s / $status |
| Bytes sent | Size of the response body | %b / $body_bytes_sent |
| Referrer | The page that linked to the resource | %{Referer}i / $http_referer |
| User agent | The client's self-reported identity | %{User-agent}i / $http_user_agent |
Three things in that list matter for analytics. The status code is something a browser script never sees, so logs are the place to count 404s and 5xx errors. The user agent is self-reported, so a bot can claim to be a browser. And the client address is a personal identifier in many legal contexts, so raw logs need the same care as other personal data. Apache also warns that client-supplied values such as headers are logged without escaping, so handle raw logs with care.
How do logs and tracking scripts compare?
| Server log | Tracking script | |
|---|---|---|
| Sees every request, including bots that skip JavaScript | Yes | No, only clients that run the script |
| Needs code on the page | No | Yes |
| Status code and server errors | Yes | No |
| Response time and bytes | Yes | Only via browser timing |
| Time on page, scrolls, clicks, custom events | No | Yes |
| Page views inside a single-page app without a new request | No | Yes, if the app reports route changes |
| Pages served from a cache or CDN | Missing from the origin log; present in the edge log | Counted when the script runs |
| Humans vs bots | Hard; guess from user agent and IP | Easier: most simple bots never run the script, and the rest can be classified |
| Affected by ad blockers | No | Some are blocked |
| Privacy | Records the IP address for every request | Depends on what the script collects |
If you need one sentence: logs are good at what the server did, and scripts are good at what the person did.
| Question | Server log | Tracking script |
|---|---|---|
| Sees bots that skip JavaScript | Yes | No |
| Status codes and server errors | Yes | No |
| Time on page, clicks, custom events | No | Yes |
| Pages served from a CDN cache | Edge log only | When the script runs |
| Affected by ad blockers | No | Some blocked |
| Needs code on the page | No | Yes |
Based on the Apache and Nginx documentation and how tracking scripts run in a browser.
What does a reconciliation look like?
Sample data: one day of requests from a content delivery network's edge log, 10,000 lines. Every row can be recomputed from the one before it.
| Step | Lines | How it is obtained |
|---|---|---|
| All log lines | 10,000 | Every request the edge saw |
| Images, scripts, stylesheets | 5,500 | Static files |
| API and background calls | 600 | Data requests the pages make |
| Page (HTML) requests | 3,900 | 10,000 − 5,500 − 600 |
| Declared bots among page requests | 1,400 | User agent says it is a crawler (35.9% of 3,900) |
| Error responses (404, 5xx) | 180 | Not served pages |
| Likely human page views | 2,320 | 3,900 − 1,400 − 180 |
| Page views in the tracking script | 2,150 | Script analytics for the same day |
Three conclusions follow:
- Counting all lines overstates traffic 4.7 times: 10,000 ÷ 2,150 = 4.65. Most lines are not pages.
- The log and the script differ by 170 page views, or 7.3% (2,320 − 2,150 = 170; 170 ÷ 2,320). That is plausible: visitors who blocked the script, left before it ran or came from clients that do not run JavaScript. A gap of a few percent is normal; a gap of 30% means something is broken or the bot filter is wrong.
- An origin log would show a different number again. If a CDN answers 38% of page requests from its cache, the origin sees only 62%: 0.62 × 3,900 = 2,418 page lines, and it cannot tell which of the missing 1,482 were people. Always say which log you used.
One day: from log lines to human page views
What are the bot and cache caveats?
- Bots read logs more completely than scripts. A crawler that never runs JavaScript appears in logs and not in script analytics, which is why a log is the right place to check crawl health. Many bots also use a browser-like user agent. Treat a user-agent filter as a lower bound on bots, not a complete one. See bot traffic for how classification works.
- A cache can hide visits from your origin. A browser cache, a CDN and an HTTP 304 response each mean a page view that never produces a normal 200 line at your server. Use edge logs if you use a CDN.
- IP addresses are not people. Offices and mobile networks share one address, and one person can use several. Counting unique IP addresses as visitors undercounts shared networks and overcounts roaming people.
- Sessions are guesses. Logs have no session ID. Grouping requests by IP and user agent within 30 minutes is an approximation.
- Log formats and time zones differ. Check that the time zone in each line matches the one in your reports.
- Raw logs are personal data. Because each line carries an IP address, decide how long to keep them and who can read them, and truncate or delete old files on a schedule. Rotating and compressing logs (Nginx can write them gzip-compressed with the
gzipparameter) saves disk, but it does not change what they contain. - Some lines are not visits. Health checks from a load balancer, uptime monitors and HEAD requests all create lines. Filter them by path or user agent before counting.
When should you use logs, a script or both?
- If you need crawl and error data (which bots, which status codes, how fast the server answered), use the log.
- If you need what people did on the page (clicks, scroll, conversion events), use a script.
- If you must not add code to the page, or need counts that do not depend on the visitor's browser, logs are a practical starting point, with the privacy care noted above.
- If the logs and the script disagree by more than about 10%, check the bot filter, the CDN and whether the script loads on every page before trusting either.
- If you use both, pick one as the source for each metric: logs for requests, status codes and crawlers; script for people, sessions and conversions. Never add them together.
A quick way to see the shape of a log without a tool, for a log in the combined format:
awk '{print $9}' access.log | sort | uniq -c | sort -rn
This prints how many requests returned each status code (field 9 in the combined format). If the number of 404s or 5xx surprises you, you have found something worth checking.
How do you combine logs and a script in TapCub?
TapCub counts people with its script and takes logs for what the script cannot see, which is crawlers.
- Install the script from Web analytics › Configuration › SDK code. This gives visitors, sessions, sources, events and goals. Real people and recognized bots are counted separately, so bots do not inflate your visitor numbers.
- Create an API key with the Import logs scope under Configuration › Settings › API keys.
- Send combined-format lines. Post Nginx or Apache combined-format lines (at most 5,000 per call) to the log import endpoint. TapCub parses only the combined format, with an optional trailing response time in seconds.
- Know what is kept. TapCub keeps only the lines it classifies as bots and drops human lines, so your visitor numbers do not change. In Web analytics › Bots, crawlers that never ran the script now appear, and in Monitoring › Crawl health the 4xx and 5xx responses are split out of the success rate. Before an import, script records carry no status code, so they count as successes.
- Read the result. The response tells you how many lines were posted, parsed, accepted as bots and skipped. If posted is greater than parsed, the line format did not match.
TapCub is not a log analyzer for people's page views: it uses logs to understand crawlers and relies on the script for human traffic. The step-by-step guide is in import server logs.
FAQ
What is web server analytics?
It is the measurement of website traffic from the web server's access log, which records every request with its time, path, status code, referrer and user agent. It needs no code on the page, but it also counts bots, assets and cache effects that a browser-based script does not.
What is the difference between log-based and script-based analytics?
Log-based analytics reads the server's record of requests and sees everything the server handled, including bots and status codes. Script-based analytics runs in the browser and sees what the person did, including clicks and time on page. Logs describe the server; scripts describe the visitor.
Are server logs more accurate than a tracking script?
They are more complete for requests and less accurate for people. Logs include bots, images and API calls, and a cache or CDN can hide real visits from the origin. A script misses blocked visits. Use logs for crawlers and errors, and a script for people.
Can server logs identify unique visitors?
Only roughly. Logs have an IP address and user agent but no durable ID, so shared networks and roaming users distort the count. A script with a first-party identifier gives a cleaner unique-visitor number.
How do I check what Nginx or Apache logs?
Both default to a combined format with the client address, time, request line, status code, bytes, referrer and user agent. In Nginx, the access_log directive writes to a path with the combined format unless you set another; in Apache the CustomLog and LogFormat directives control it.
Sources
- Apache HTTP Server documentation, Log Files (access log, Combined Log Format fields, unescaped client values). Checked 2026-11-23.
- Nginx documentation, ngx_http_log_module (the predefined
combinedformat andaccess_log). Checked 2026-11-23.
Was this article helpful?
We use your answers to fix and expand this page.
Couldn’t send. Please try again in a minute.
Thanks for the feedback. We’ll use it to improve this page.You’ve already sent feedback on this page. Thanks.

Product Experience Specialist
Writes about product experience, practical workflows, and growth, turning complex processes into clear steps for everyday decisions.
