Free website visitor counter: add one in 2 minutes (HTML code)
Old-school hit counters showed a number on the page — "You are visitor #10,482". Today most people want the same information privately: how many visitors came, from where, and what they looked at. Here is how to add a free counter to any site.
Public hit counter vs analytics counter
| Public hit counter widget | Analytics counter | |
|---|---|---|
| Shows | One total number on your page | Visits, visitors, sources, pages, devices, goals |
| Who sees it | Every visitor | Only you (or a share link) |
| Accuracy | Often counts reloads and bots | Filters bots, counts visits properly |
| Looks | Dated widget | Invisible |
Unless the number on the page is part of your design, an analytics counter is the better choice.
Add a free counter with one line of HTML
With LightMetrica the whole setup is:
- Create a free account and add your site's address.
- Copy your tracking code:
<script defer src="https://lightmetrica.com/lm.js" data-site="YOUR-ID"></script>
- Paste it before
</head>in your site's template so it loads on every page. - Open your site. The counter page shows "Active" after the first visit — usually within seconds.
The script is about 2 KB, loads asynchronously and doesn't use cookies, so it won't slow your pages or require a cookie banner for the counter itself.
Where to paste the code
- Plain HTML site — in the shared header file or every page's
<head>. - WordPress — install a plugin like WPCode ("Header & Footer"), paste the code into the header field.
- Google Tag Manager — new tag → Custom HTML → paste → trigger "All Pages" → publish.
- Website builders (Tilda, Webflow, Squarespace and others) — look for "custom code", "head code" or "header injection" in site settings.
- Single-page apps (React, Vue, Next.js) — add the tag once; page changes inside the app are tracked automatically.
Detailed instructions: WordPress, Wix, Shopify, Webflow, Next.js.
What you'll see
- visits, unique visitors and pageviews with a comparison to the previous period;
- traffic sources — search engines, social networks, messengers, AI assistants, ads and other sites;
- popular pages, entry and exit pages, time on page and scroll depth;
- devices, browsers and countries;
- automatic goals: clicks on phone numbers, email addresses and messenger links, file downloads, outbound links.
Want to show the numbers to someone else? Turn on a public link in the counter settings — read-only, no account needed. Here is ours: live stats.
Excluding your own visits
Open your site once with ?lightmetric=ignore at the end of the address (for example https://example.com/?lightmetric=ignore) in each browser you use. The counter will skip your visits from then on.
Try LightMetrica — free
Lightweight, independent, cookie-free analytics: the counter installs in a minute — on its own or next to your current tools. Every week — an AI-powered Smart Report: what changed and what to do next.