TapCub is live — analytics, insights and live chat, free on one platform
Analytics

Web server analytics: logs vs script-based tracking

What a web server access log can and cannot tell you compared with a tracking script: the fields in a log line, a one-day reconciliation from 10,000 log lines to 2,320 human page views, and the bot and cache caveats.

Lin Zhou Published Nov 23, 2026 11 min read Analytics
Sample data: only 39% of log lines are page requests, and after removing bots and errors the log (2,320) and the script (2,150) differ by 7.3%.Sample data

Web 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.

FieldMeaningApache / Nginx name
Client addressThe IP address that connected (may be a proxy, not the person)%h / $remote_addr
Identity and userTwo fields, almost always -%l %u / $remote_user
TimeWhen the request was received%t / $time_local
Request lineMethod, path and protocol, for example GET /pricing HTTP/1.1%r / $request
Status code2xx success, 3xx redirect, 4xx client error, 5xx server error%>s / $status
Bytes sentSize of the response body%b / $body_bytes_sent
ReferrerThe page that linked to the resource%{Referer}i / $http_referer
User agentThe 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 logTracking script
Sees every request, including bots that skip JavaScriptYesNo, only clients that run the script
Needs code on the pageNoYes
Status code and server errorsYesNo
Response time and bytesYesOnly via browser timing
Time on page, scrolls, clicks, custom eventsNoYes
Page views inside a single-page app without a new requestNoYes, if the app reports route changes
Pages served from a cache or CDNMissing from the origin log; present in the edge logCounted when the script runs
Humans vs botsHard; guess from user agent and IPEasier: most simple bots never run the script, and the rest can be classified
Affected by ad blockersNoSome are blocked
PrivacyRecords the IP address for every requestDepends 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.

QuestionServer logTracking script
Sees bots that skip JavaScriptYesNo
Status codes and server errorsYesNo
Time on page, clicks, custom eventsNoYes
Pages served from a CDN cacheEdge log onlyWhen the script runs
Affected by ad blockersNoSome blocked
Needs code on the pageNoYes

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.

StepLinesHow it is obtained
All log lines10,000Every request the edge saw
Images, scripts, stylesheets5,500Static files
API and background calls600Data requests the pages make
Page (HTML) requests3,90010,000 − 5,500 − 600
Declared bots among page requests1,400User agent says it is a crawler (35.9% of 3,900)
Error responses (404, 5xx)180Not served pages
Likely human page views2,3203,900 − 1,400 − 180
Page views in the tracking script2,150Script analytics for the same day

Three conclusions follow:

  1. Counting all lines overstates traffic 4.7 times: 10,000 ÷ 2,150 = 4.65. Most lines are not pages.
  2. 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.
  3. 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.
app.tapcub.com

One day: from log lines to human page views

All log lines10,000
Page (HTML) requests3,900
Likely human page views2,320
Page views in the script2,150
Sample data
Sample data: only 39% of log lines are page requests, and after removing bots and errors the log (2,320) and the script (2,150) differ by 7.3%.

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 gzip parameter) 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?

  1. If you need crawl and error data (which bots, which status codes, how fast the server answered), use the log.
  2. If you need what people did on the page (clicks, scroll, conversion events), use a script.
  3. 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.
  4. 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.
  5. 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.

  1. 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.
  2. Create an API key with the Import logs scope under Configuration › Settings › API keys.
  3. 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.
  4. 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.
  5. 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 combined format and access_log). Checked 2026-11-23.
Filed underAnalytics

Was this article helpful?

We use your answers to fix and expand this page.

Lin Zhou

Product Experience Specialist

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

See people with a script and crawlers with logs

Visitors from one script, plus crawler status codes from imported server logs, reported separately.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics