ABV Nexus home

>> Notes /

SirChesterCoon: visitor countries without keeping a single address

This note is about the statistics on the SirChesterCoon website.

What I wanted to know

For a channel site, a few numbers matter: how many people visit, from which platform they came, on what kind of device, and roughly where in the world they are. Brands ask about audience countries.

What I did not want was the usual price for those numbers: a third-party analytics script, a cookie banner, and a log of visitor addresses sitting on a server.

Only counts reach the database

The website stores one kind of statistics row: a day, a dimension and a count. For example "this day, country NL, 14" or "this day, source instagram, 31". Nothing in the database can be traced back to a person, because nothing about a person is in it. Rows older than 25 months are deleted automatically.

The dimensions are deliberately coarse:

  • page, from a short fixed list;
  • source, reduced to instagram, tiktok, youtube, facebook, google, other or direct;
  • device, as phone, tablet or desktop;
  • country, as a two-letter code or "Unknown".

Countries from an offline table

Country lookups use a free, openly licensed table of address ranges that the server downloads once a month and checks before using. No visitor data is sent anywhere to get a country: the lookup happens in memory, against that table.

The table is loaded into compact typed arrays, one set for IPv4 and one for IPv6, sorted by range. A lookup is a binary search, so it stays fast however large the table gets. IPv4 addresses written in IPv6 form are recognised as the IPv4 address they are. Ranges the table marks as unknown are counted as "Unknown" rather than guessed.

The address is used for that one lookup and then dropped. It is never written to the database.

Not counting the same person twice in a burst

Without cookies there is no visitor ID, but a counter still needs some protection against one browser firing hundreds of events. For that, the server keeps a short-lived fingerprint in memory: a keyed hash of the address and browser string, with a random key that is replaced every day. The fingerprints are cleared every minute and are never stored. Known bots and link previewers are not counted at all.

The trade-off

These numbers are approximate on purpose. Someone who visits on Monday and Tuesday counts twice. A VPN shows up as the VPN's country. There are no visitor journeys, no returning-visitor rates and no individual sessions to inspect.

In return, there is nothing to leak, nothing to consent to and no outside company watching the channel's audience. For the questions a creator site actually has to answer, that has been the right side of the trade.