Privacy-first, no-nonsense web analytics.
Bearlytics is exactly what it says on the tin - a straightforward web analytics tool that helps you understand your website traffic without selling your soul to the tracking gods. No cookies, no PII problems, just the basics:
- Page views
- Referrers
- Country
- Device type
- Browser
Because sometimes you just want to know how many people visited your blog post about artisanal toast without signing up for an enterprise-grade solution.
After struggling to self-host popular open-source analytics platforms like Plausible and Umami (which require multiple services and complex setups), I decided to build something simpler and self-contained with Django and SQLite.
- 🔒 Privacy-focused: No cookies, no personal identifiable information
- 🚀 As many websites as your server can handle
- 📊 Clean, intuitive dashboard
- 🔍 Filter by date range, page path, and referrer
- 📱 Responsive design that won't make your eyes bleed
- 💾 Self-hosted, because your data belongs to you
Bearlytics uses a straightforward Django configuration with SQLite as the database. Key settings include:
- Database: SQLite with WAL journal mode and optimized cache settings for better performance
- Environment Variables (using .env in the dev environment):
SECRET_KEY
: Django secret keySALT_SECRET
: Secret key used to hash PIIDEBUG
: Set to False in productionDB_PATH
: SQLite database location (default: /app/db/db.sqlite3)ALLOWED_HOSTS
: Comma-separated list of allowed hostsCSRF_TRUSTED_ORIGINS
: Comma-separated list of trusted origins
The SQLite database is configured with performance optimizations:
- Increased cache size
- Write-Ahead Logging (WAL) journal mode
- Normal synchronization mode
Q: Is it production-ready?
A: I've been running it in production on my personal blog (~50,000 page views/month), and JustSketchMe (~150,000 page views/month) since November 2024. So far, nothing has exploded.
Q: Is this better than Google Analytics?
A: For tracking your cat blog? Probably. For enterprise-level analytics needs? I'd recommend something more robust, like Fathom.
Q: Will this make me rich and famous?
A: No, but it will tell you how many people read your blog post about getting rich and famous.
Q: Do I need a cookie consent banner?
A: No, but you can add one if you want.
Q: Can I use this for my business?
A: Yes, but if you want to offer it as a service to your customers, check out the full license.
Q: How is user privacy protected?
A: User privacy is protected by not storing any personal identifiable information (PII). The IP address is hashed alongside the user-agent, and the current date with SHA-256 using a salt string that is stored in the environment variables. Can this be reversed? Yes, but it would require a lookup table of all possible IP addresses, user-agents and dates, along with their corresponding salted hashes, and a computer the size of a small moon.
The lookup table would need approximately 11,400 TB (or about 11.4 petabytes) of storage
This assumes:
- All possible IPv4 addresses (4.3 billion)
- 250 common user agent combinations (5 browsers × 5 OS × 10 versions)
- 365 days of dates
- 32 bytes per SHA-256 hash
Time to Generate:
Even at a rate of 1 million hashes per second, it would take about 12.4 years to generate the complete table (and then you'd have to query it). All so you can get a rough idea of which IP address visited your site.
Q: What about back-ups/data exporting?
A: The database is stored in a SQLite database file on your server. You can back it up any way you want. I personally use a cron job to back it up to an S3 bucket every 24 hours.
Q: Can I pay you to host my analytics?
A: No, but if it's something you're interested in, let me know by commenting on this issue, and I may add it to the roadmap.
This is a basic Django app that can be deployed to any platform that supports Django.
I've chosen Dokku for this guide because it's easy to set up and manage, and I'm familiar with it.
- A Dokku server
- Basic knowledge of terminal commands
- A cup of coffee
# Create the app
dokku apps:create analytics
# Create persistent storage for SQLite
dokku storage:ensure-directory analytics
dokku storage:mount analytics /var/lib/dokku/data/storage/analytics:/app/data
# Set environment variables
dokku config:set analytics SECRET_KEY=your_very_secret_key_here
dokku config:set analytics DB_PATH=/app/data/analytics.db
dokku config:set DISABLE_COLLECTSTATIC=1
dokku config:set SALT_SECRET=your_very_secret_salt_here
dokku config:set DEBUG=False
Add Dokku as a remote and commit and push your code
git remote add dokku dokku@your-server:analytics
git push dokku main
- Visit
https://your-analytics-domain.com
- Create an account (if no user exists, the first user will be automatically promoted to admin)
- Add your website
- Copy the tracking script
- Add it to your website's
<head>
section - Watch those sweet, sweet analytics roll in
For hosting with Docker Compose:
- Create a directory to hold the configuration .
mkdir -p /opt/bearlytics
- Create a subfolder
analytics/
to store the data. - Create a
.env
file with (at least):SECRET_KEY=your_django_secret_key SALT_SECRET=your_secret_salt
- Review docker-compose.yaml for any other needed changes, such as adjusting the
UID
/GID
to match the ownership of theanalytics/
directory:services: bearlytics: image: ghcr.io/hermanmartinus/bearlytics:latest ports: - 8000:8000 volumes: - ./analytics:/app/data environment: CSRF_TRUSTED_ORIGINS: ${CSRF_TRUSTED_ORIGINS:-http://localhost} DB_PATH: ${DB_PATH:-/app/data/analytics.db} DEBUG: False SALT_SECRET: ${SALT_SECRET:?err} SECRET_KEY: ${SECRET_KEY:?err} UID: 1000 GID: 1000 restart: unless-stopped
- Deploy the app:
docker compose up -d
For production deployments, serve Bearlytics behind a reverse proxy like Caddy or nginx. A Caddy configuration could be as simple as:
bearlytics.example.com {
reverse_proxy http://localhost:8000
}
<script async defer src="https://your-analytics-domain.com/script.js" data-website-id="your-website-id"></script>
I'm still figuring out the best license model for Bearlytics. For now, here's the plan:
- You can self-host and modify Bearlytics for your own use, no strings attached
- Commercial hosting or re-selling of Bearlytics requires a commercial license (email me)
For the full license text, see LICENSE
Pull requests are welcome. To be certain we're on the same page, please open an issue first to discuss what you would like to change.
- Coffee ☕
- That one Stack Overflow answer that saved my life (you know who you are) 🙏
- SQLite (you're doing great!) 👌
- Emma (thanks) ❤️
Made with love and probably too much caffeine by Herman Martinus