How to count unique visitors without cookies

Without a cookie there's no ID to count. Every cookie-free method picks something to stand in for a person and decides how long it lasts, and each one gets a different part of the number wrong.

9 min read

Summarize with

In this article
  1. 1A unique visitor is a stand-in, not a person
  2. 2Method 1: a daily rotating hash
  3. 3Method 2: a random token in browser storage
  4. 4Method 3: count arrivals, not people
  5. 5Method 4: server logs
  6. 6What not to do: fingerprinting
  7. 7The four side by side
  8. 8How to choose

With a cookie, counting unique visitors is easy: give each browser a random ID, then count the distinct IDs. Without one, there is nothing to count until you decide what “the same visitor” means, and every way of deciding gets part of the number wrong.

Here are the four methods that cookie-free tools and hand-built setups use, where each one miscounts, and how to pick one. Running a whole site without a banner is a bigger subject, covered in what it takes to run a website without a cookie banner. This article is about one number.

A unique visitor is a stand-in, not a person

No analytics tool counts people. It counts something that stands in for a person, such as a cookie, a token, a hash or an IP address, and “unique visitors” is the number of distinct stand-ins it saw in a period. So every method comes down to two questions:

  1. What is the stand-in?
  2. How long does it last?

The second matters as much as the first. A stand-in that lasts a day can count visitors per day. It can't tell you whether Monday's visitor came back on Thursday.

Cookie counts were never exact either. People clear cookies, open private windows and switch from phone to laptop. And as of November 2026, Safari's tracking prevention deletes cookies set by JavaScript, and local storage with them, after seven days without the visitor interacting with the site. Every method below is an estimate. The aim is one whose errors you know.

Method 1: a daily rotating hash

Several privacy-focused analytics tools work this way. On every pageview the server combines a few values that stay fairly stable for one browser during one day, and hashes them. Plausible publishes its formula in its data policy (as of November 2026):

hash(daily_salt + website_domain + ip_address + user_agent)
  • The daily salt is a random secret that is replaced every day and deleted, so yesterday's keys can't be recreated.
  • The website domain makes the key different on every site, so it can't follow anyone from one site to another.
  • The IP address and user agent are what the browser sends with every request anyway. They're used to work out the key, and the raw values aren't kept.

Matomo sets a cookie by default, and without one it falls back on traits like these. Its key, which it calls config_id, is built from the operating system, browser, plugins, IP address (anonymised by default) and language, with a random seed it discards every day. Same browser, same network, same day: same key, counted once. Next day there's a new salt and a new key, and nothing links the two.

Where it miscounts:

  • Returning visitors on later days. Someone who visits on Monday and Thursday is two unique visitors. A month's unique visitors is close to the sum of each day's, so a site with loyal readers sees a bigger number than a long-lived cookie would give.
  • Changing networks. A phone that moves from Wi-Fi to mobile data gets a different IP address, and with it a new key, halfway through the day.
  • Browser updates. The user agent contains the browser's version, so an update during the day can change the key.
  • Shared addresses. An office often shares one public IP address, and mobile carriers often put many customers behind one. Chrome also sends the same reduced user agent for every copy of the same major version on the same platform, so two colleagues on up-to-date Chrome can produce one key and count as one visitor.

The first three push the count up. The last one pulls it down.

Nothing is stored on the visitor's device, which is the main reason this method is popular. It isn't automatically outside the rules, though. The European Data Protection Board's 2024 guidelines on the cookie rule read it broadly. They say it can apply when information a browser sends anyway, such as the IP address or the user agent, is used to track people. They also say that the rule applying doesn't automatically mean consent is needed, and they don't analyse daily-hash analytics as such. If the answer matters to your business, ask a lawyer where you operate.

Method 2: a random token in browser storage

Generate a random ID the first time a browser visits and keep it in localStorage. It behaves like a cookie without being one, and it does the one thing a daily hash can't: recognise the same browser on a later day.

The catch is legal, not technical. The EU rule behind cookie banners, Article 5(3) of the ePrivacy Directive, is about storing information on the visitor's device or reading it from there, whatever the mechanism. The same EDPB guidelines name local storage alongside cookies, and say there is no minimum time the information has to stay for the rule to apply. Moving an ID from a cookie into local storage doesn't make the consent question go away. Whether an exemption applies is a question for where you operate, and the cookie-free website guide covers the rule in more detail.

A token also has the cookie's other weaknesses. Every device, every private window and every cleared browser gets a new one, and Safari's seven-day rule applies to local storage too, so someone who reads your site every two weeks on an iPhone can arrive as new each time.

It's the right choice when you've decided you really need returning visitors across days, and you're ready to ask for consent where that's required.

Method 3: count arrivals, not people

This method doesn't identify anyone. A pageview counts as a new visitor when it didn't come from your own site: from a search result, a link somewhere else, or with no referrer at all. A click on an internal link is the same visit carrying on.

As of November 2026, Simple Analytics counts its visitors this way and says plainly that they are really unique pageviews. Reloads and back-and-forward navigation don't count. Cloudflare Web Analytics defines a visit the same way, as a page view whose referrer doesn't match the site's hostname.

It stores nothing and is easy to explain. Its limits:

  • It counts arrivals. Someone who comes from search in the morning and from a newsletter in the afternoon is two. The number is closer to visits than to visitors.
  • It depends on your own referrer policy. Browsers send a referrer by default, but a site that sets Referrer-Policy: no-referrer removes it from internal clicks as well, and then every pageview looks like a new arrival. Check your headers before you trust the count.
  • Single-page apps need care. When a page changes without a full load, there's no new document, so document.referrer still names wherever the first page came from. Unless the tool handles in-app navigation itself, every page change looks like a fresh arrival from that source.

A visit with no referrer counts as new here, the same way it lands in direct traffic in a sources report. For counting, that's usually right: something brought the person in from outside.

Method 4: server logs

Count distinct pairs of IP address and user agent per day in your web server's access log. It needs no JavaScript, and it sees visitors who block scripts. The data is often already there: nginx's default log format, for example, records both for every request.

In effect it's method 1 without the salt. The same pair can be matched across days, which is exactly what makes it more sensitive. The trade-offs:

  • You're storing full IP addresses. In the Breyer case in 2016, the EU's Court of Justice held that even a dynamic IP address can be personal data for a website operator. Keep raw logs for a short time and keep only daily counts after that.
  • Bots are in there. Many crawlers don't run JavaScript, so they show up in a log count even when a script-based tool never sees them. Filter out known bots, and count only requests for pages, not for images, scripts and stylesheets.
  • Proxies hide the visitor. Behind a CDN, your server may see the CDN's address instead of the visitor's. Cloudflare, for instance, says one of its own addresses is logged by default, with the visitor's address in a CF-Connecting-IP header your server has to be set up to read.
  • Shared addresses merge people, exactly as in method 1.

What not to do: fingerprinting

Fingerprinting combines many browser traits, such as screen size, installed fonts, time zone and the way the browser draws graphics, into an ID that lasts. Its selling point is that clearing cookies doesn't reset it. That's also the problem: the visitor can't see it, can't clear it and has no easy way to opt out.

It doesn't get around the rules either. EU data-protection authorities concluded in 2014 that fingerprinting falls under the same article of the ePrivacy Directive as cookies, and the EDPB's 2024 guidelines build on that. They add that using the browser's cache for the same purpose, for instance through an ETag, can fall under it too. If the reason you dropped cookies was privacy, fingerprinting defeats the purpose.

The four side by side

MethodStored in the browserSame person on a later dayMain error
Daily hashNothingCounted againCounts too high across days and network changes; can merge people who share an IP address and browser version
Token in storageA random IDRecognised, until the storage is clearedA new ID per device, private window and cleared browser; covered by the same consent rule as cookies
Referrer ruleNothingCounted againCounts arrivals, not people; breaks if your own pages send no referrer
Server logsNothing, but full IP addresses on your serverCan be matched, unreliablyBots, proxies and shared addresses

How to choose

  1. Decide whether you need returning visitors across days. If the questions you actually ask are “how many people came this week, and from where?”, a daily hash or a referrer rule answers them without storing anything.
  2. If you do need them, you need a stand-in that lasts, which means a token in storage, and the consent question that comes with it.
  3. If people sign in, count accounts for them. Distinct accounts active per day, from your own database, is the most precise unique count you'll get for that group. It only covers people who sign in, so use it next to your analytics, not instead of it.
  4. Label the number. “Unique visitors (daily key)” or “arrivals (referrer rule)” in a report stops anyone comparing it with a cookie-based count from another tool. Two tools on one site will disagree anyway, and why no two analytics tools agree on your traffic covers the usual reasons.
  5. Watch the trend, not the total. One method used consistently gives a consistent trend, even when the total is off in a known direction. If you switch methods, run both for a while and start a new trend line on the day you switched.
A unique-visitor count is only as good as your answers to two questions: what stands in for a person, and for how long.

Lomen's script sets no cookies and, by default, stores nothing in the visitor's browser, and Lomen never stores IP addresses. A returning visitor is counted once a day from an anonymous key that changes daily, so the cross-day trade-off above applies: someone who comes back on Thursday counts again. A site owner can opt in to a random token in browser storage to recognise returning visitors across days, with the consent question that comes with it. Lomen does no fingerprinting and uses no cross-site identifiers.

Numbers you can ask questions

Lomen is one cookie-free script: sources, campaigns and AI referrals on one dashboard, and an AI that answers from your own figures. Free during the beta, no credit card.