How to Track Visitors on a Static HTML Page

You published a page and sent the link around. Did anyone open it? A static HTML file has no application behind it writing logs you can query, so the answer has to come from somewhere else. There are three real approaches, and they differ in accuracy, privacy obligations and how much work they are.

Approach 1: Server-side counting (nothing added to your page)

Every web server writes an access log — one line per request, with timestamp, path, response size and user agent. If your host aggregates that log for you, you get visit counts without adding a single byte to your HTML.

This is how hdply's built-in statistics work: the server tails its own access log and rolls it up per site per day, with visitor IP addresses hashed rather than stored. Nothing runs in the visitor's browser.

Why that matters more than it sounds:

  • Ad blockers can't block it. Client-side analytics miss a substantial share of technical audiences — commonly cited as 10–30% depending on who's visiting. Server-side counting sees every request that reaches the server.
  • Zero performance cost. No extra script to download, parse and execute.
  • No cookie banner needed for it. No cookie is set and no personal identifier is stored, which keeps you out of consent-banner territory entirely.

What you don't get: depth. Log-based counting gives you views, unique visitors and bandwidth per day. It can't tell you how far someone scrolled, which button they clicked, or how long they stayed — that requires code running in the browser. It also can't perfectly separate bots from people; crawler traffic inflates raw view counts on every log-based system.

Use it when you want to know whether anyone is showing up and roughly how many — which for a portfolio, an invitation or a shared proposal is the entire question.

Approach 2: Privacy-friendly analytics scripts

Plausible, Fathom, Umami and similar are small scripts (typically about 1 KB) that count page views without cookies or cross-site tracking. Most are paid, though Umami is open source and self-hostable.

<!-- one line, before </head> -->
<script defer data-domain="mysite.example.com"
        src="https://plausible.io/js/script.js"></script>

You get referrers (where visitors came from), top pages, countries, and device breakdown, on a dashboard that takes a minute to understand rather than an afternoon. Because no cookie is set and no personal data is stored, most of these vendors state that no consent banner is required — verify that against your own jurisdiction rather than taking a vendor's word for it.

The trade-off: ad blockers block some of these too, so counts run lower than reality. And it's another external script on your page.

Approach 3: Google Analytics 4

Free, and the most capable of the three by a wide margin: conversions, funnels, audience segments, integration with Search Console and Ads.

<!-- replace G-XXXXXXXXXX with your measurement ID -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

The trade-offs are real. It's the single most-blocked script on the web, so it undercounts most. It's heavier than the alternatives. The interface is built for marketing teams and is genuinely hard to use for "how many people saw my page". And because it processes personal data, using it in the EU/UK means a consent banner and a privacy policy — a legal obligation you're taking on, not a checkbox.

Use it when you're running ads, optimising conversions, or already live in the Google marketing stack.

Comparing them

Server-side logsPrivacy analyticsGoogle Analytics 4
Code on your pageNone~1 KB script~50 KB+ script
Blocked by ad blockersNoSometimesVery often
Cookie bannerNoUsually noYes, in EU/UK
Referrers & countriesNoYesYes
Events & funnelsNoLimitedYes
CostIncludedMostly paidFree

What to actually do

For a personal page, a portfolio or a link you sent to twenty people: use whatever your host gives you and add nothing. The question is "did anyone come?", and a daily view count answers it.

For a page you're promoting and want to improve: add a privacy-friendly script for referrers, so you learn which channel is working.

For a business page tied to ad spend: Google Analytics, with the consent banner and privacy policy that legally accompany it.

A useful habit regardless: whatever tool you choose, look at it weekly for a month, then decide whether it changed a single decision you made. If it didn't, you're collecting data as a hobby, and removing the script makes your page faster.

Common questions

Why do two tools report different numbers? They count different things — server logs count requests including bots; scripts count browsers that executed JavaScript and weren't blocked. Expect meaningful gaps, and compare each tool against itself over time rather than against the others.

Can I see individual visitors? No, and you shouldn't try. Identifying people by IP is exactly what privacy regulation restricts, which is why well-built log analytics hash the address before storing anything.

Do I need a privacy policy? If you use Google Analytics or any tool that sets cookies or stores personal data, yes. If you rely only on aggregated server-side counts with hashed addresses, generally not — but "generally" is doing work, and your jurisdiction decides.

Related: The meta tags every page should have · Deploy without a server

From a file on your desktop to a live URL in under a minute.

Deploy your first page