Privacy Focused Analytics
My blog post: Privacy Focused Analytics From Scratch
I wanted to learn more about web analytics so I budgeted myself a few hours and built a small analytics system.
It uses a Flask application with a SQLite database, and a HTML snippet to collect anonymous user data from any website.
- Collects information about:
- What pages users visit
- Where users are referred from
- What browsers and screen sizes are used
- Which country the user is from (without an API call)
- Lets you view analytics from different time slices
Include this on any page you want to gather analytics from.
https://example.org to wherever you host the Flask application.
Download a free GeoLite2 country database to
pip install -r requirements.txt
env FLASK_APP=analytics.py flask run
The tracking pixel is hosted from
Note: It's likely that most ad blockers will stop the request.
There is a test page at
/ that will serve up the snippet for test purposes.
Analytics can be viewed at
/analytics. Search parameters can be passed to view a time slice.
start- The start of the time slice in UNIX seconds (inclusive). Defaults to
end- The end of the time slice in UNIX seconds. Defaults to current time.
Hopefully none? This was a self-contained experiment to learn more about something