I’m building a website with articles, and I’d like to count unique-per-day visits for each article.
The idea to use cookies suggests itself, but I simply can’t set a cookie for each and every article visited – ofc the user typically won’t go through everything, but better to be safe. If I put all into one cookie, I’ll run out of per-cookie space soon, too.
What’d be the best (most practical and lightweight) solution to this?
I have an sqlite database, so maybe some kind of persistent “session” data? That’ll put extra load on the server and db, though. Ideas?
This is how you are tracked without cookies via the browser fingerprint.
https://panopticlick.eff.org/index.php?action=log&js=yes
Idea: Each browser has a unique fingerprint if you get enough features
- ip address
- installed fonts
- javascript yes/no
- adblock yes/no
- accepted headers
- is some stuff cached?
- java
- screen size
If you get 20 bits out of the browser you can distinct approximately 1,000,000 users. If you only have 100 users and some features change then they are still identifiable with a high probability.
Also you can add knowledge about the
- interests of people viewing a site
- how long they visit
- how many links they click (make links traceable)
to add more information.
2
If you are concerned about load you could use redis or in-memory storage, and them periodically offload the results, see:
Python example, could be adapted to php
Uses Redis bitmaps to store the counts