How to Add Analytics to an HTML Page in 2026 (5 Methods Compared)

Ilya SpiridonovIlya Spiridonov
··7 min read

Adding analytics to an HTML page sounds like one task with one answer. It is closer to five, and the right one depends on two things most guides skip: whether you can edit the file's code, and whether you want to know how many people looked or which specific person did.

Get those two answers straight and the choice is easy. This guide walks through the five real methods, what each one actually shows you, what it costs, and the one line that tells you whether it fits. No method is best for everything, and the last one is deliberately narrow.

Two questions that decide your method

Before any tool, answer these.

Can you edit the HTML? Methods that work by pasting a script tag need access to the file's <head>. That is fine for a page you wrote. It is a problem for an export you did not, like an InDesign HTML5 package, a Claude artifact, or a Webflow code export, where editing the markup is awkward or gets overwritten on the next export.

Do you want a crowd or a person? Almost every analytics tool reports a crowd: total visits, average time, country, device. That is the right data for a public page. It is the wrong data for a page you sent to ten named buyers, where the useful answer is which of the ten opened it and how far they read.

Hold those two answers. They map cleanly onto the five methods below.

Method 1: Google Analytics 4

The default. Create a GA4 property, copy the gtag.js snippet, and paste it before the closing </head> of your HTML. It works on a single file or a whole static site, and Google's own setup docs walk through it.

What you get: deep, free, aggregate web analytics. Sessions, users, geography, devices, events, the works. What you pay for it is setup and complexity. You need a Google account, the dashboard has a real learning curve, and in most regions you will need a cookie consent banner because GA4 sets cookies.

Choose this if you can edit the HTML, you want rich aggregate data, and the page is public. It is overkill for one file you are sending to a handful of people.

Method 2: Plausible, Fathom, or Umami

The privacy-first, lighter alternative. Plausible, Fathom, and Umami all work the same way: one small script tag, no cookies, no consent banner in most cases, and a single clean dashboard of visits and top pages. The scripts are tiny, often around a kilobyte, so they barely touch load time.

The trade is depth and price. You get the numbers that matter for most sites and little of GA4's sprawl, but Plausible and Fathom are paid subscriptions. Umami is open source and free if you self-host it, which moves the cost from money to maintenance.

Choose this if you can edit the HTML, you want clean aggregate numbers without the GA4 weight or a cookie banner, and you are willing to pay a small subscription or run Umami yourself.

Method 3: Your host's built-in analytics

If the page already lives on a modern host, you may not need a separate tool at all. Vercel, Cloudflare, and Netlify all offer first-party analytics you switch on in a dashboard, no tag to paste. Cloudflare's is privacy-first and free; Vercel's and Netlify's have free tiers that cap quickly.

The catch is lock-in and depth. The data lives with that host, the free tiers are limited, and you are tied to staying on that platform. It is convenience, not a full analytics product.

Choose this if the page is already hosted on Vercel, Cloudflare, or Netlify, and aggregate counts are enough. Do not move your hosting just to get it.

Method 4: GoatCounter or a self-hosted counter

The minimalist end. GoatCounter is open source, cookie-free, and free for non-commercial use, and Simple Analytics sits nearby with the same lightweight, privacy-first spirit. You get page views, referrers, and basic breakdowns, and not much more, which is the point.

This is also the path the self-hosted crowd takes when they want to own the data outright and run it on their own server.

Choose this if you want the lightest possible footprint, no cookies, and either a free hobby counter or full self-hosted control, and you are happy with minimal numbers.

The first four methods all answer "how many." They also all assume the page is public and that you can edit its code. Method 5 is for the case none of them cover: the HTML is not a public site, it is an artifact you are sending to specific people, and you want to know which of them engaged.

Here you do not add a tag at all. You upload the HTML file or bundle to a platform that hosts it and tracks it for you, then send each recipient their own link. Because the tracking wraps the file from the outside, it works on exports you cannot easily edit, an InDesign HTML5 package, a Claude or v0 artifact, a Webflow export. And because each link is unique to a person, the report is per-recipient: which named viewer opened it, which pages they spent time on, whether they came back, whether a forwarded link reached someone new.

That is what HummingDeck does. Upload the HTML, send tracked links, and see per-page engagement on /share/html by person rather than as a crowd. You also get the things a tag cannot give you: a verified-email allowlist so only your intended recipients can open the page, link expiry, and bot filtering that drops corporate scanners like SafeLinks and Proofpoint out of the numbers.

This is not a GA4 replacement

HummingDeck is not a drop-in analytics tag for your existing Webflow, WordPress, or marketing site. For a public site you control, use Method 1 or 2. Method 5 only makes sense when the page is something you send to a known list of people, and per-recipient attribution matters more than aggregate traffic. Narrow on purpose.

Choose this if you are sending an HTML one-pager, proposal, prototype, or export to specific clients, investors, or prospects, you cannot or do not want to edit the file to add a tag, and you need to know who looked rather than how many.

Which method to pick

MethodSetupCookie bannerWhat you seeBest for
Google Analytics 4Paste a tag, Google accountUsually yesDeep aggregate, anonymousPublic sites you can edit
Plausible / Fathom / UmamiPaste a small scriptNoClean aggregate, privacy-firstPublic sites, lighter than GA4
Host built-in (Vercel, Cloudflare, Netlify)Toggle on in dashboardVariesBasic aggregatePages already on that host
GoatCounter / Simple AnalyticsSmall script or self-hostNoMinimal countsMinimalist or self-hosted
Tracked link (HummingDeck)Upload the file, no tagNoPer-recipient, per-page, gatedSending HTML to specific people

The honest summary: if the page is public and you can edit it, the answer is Google Analytics 4 or a lightweight tag like Plausible, and the host's built-in stats if you happen to be on Vercel, Cloudflare, or Netlify. If the page is something you are handing to a named list of people, a tracked link answers the question those tools cannot, which is not how many looked, but who.


Related reading