About this project
Smart-analytics is a minimalist, privacy-focused self-hosted website analytics system, derived from tiny-analytics 0.1.3. Its core enhancement is support for multi-site/multi-tenant management: a single account can manage multiple sites, each with independent tracking scripts and completely isolated data.
The tech stack uses Python FastAPI + SQLite (single database, multi-tenant), running as a single process without external services or databases. The mechanism works by having the visitor's page load send a POST request from the tracking script to the server. The server generates an anonymous visitor ID using a hash of "site ID:IP:UA", with raw IPs not stored. When the user leaves the page, a beacon reports the time spent; dashboards aggregate and visualize data by site.
Key features include:
- Privacy-first: No cookies, no localStorage, no fingerprinting, cross-site tracking disabled
- Multi-site/multi-tenant: Each site has its own token, fully isolated data; supports multiple users and site members
- Account system: Email/password registration/login, web interface for managing sites and members
- Offline GeoIP location: Based on DB-IP database, provides country/province/city-level geographic info without third-party APIs
- Bot filtering: Automatically identifies and filters out bot traffic
- High-frequency IP module: Identifies high-frequency access IPs and displays their locations
- Page dwell time: Records actual interaction duration
- Geographic and device distribution: Statistics on visitor origins and device types used
- Popular pages and traffic sources: Top pages ranking, referring domains, and search keywords
- Traffic timing distribution: Observe patterns by 24-hour/weekly dimensions
- Period-over-period comparison: Changes in unique visitors, page views, and dwell time over time
- Real-time online: Number of online users in the last 5 minutes, dashboard auto-refreshes
- New vs. returning visitors: Distinguished via anonymous identifiers
- UTM channel tracking: Statistics grouped by source/media/campaign
- Session analysis: Bounce rate, average session duration, entry/exit pages (estimated)
- Browser/os distribution:粗粒度 User-Agent-based statistics
- Flexible time ranges: Support for 1 hour/2 hours/24 hours/7 days/30 days, with selectable stat intervals of 1/5/15 minutes/1 hour
- Dark mode UI
Configuration is controlled via environment variables: SMART_ANALYTICS_PASSWORD (admin password), SMART_ANALYTICS_SECRET_KEY (session signing key), SMART_ANALYTICS_ALLOWED_ORIGINS (CORS domain restrictions), SMART_ANALYTICS_DB_PATH (database path), etc.
Deployment includes one-click scripts (deploy/linux/setup.sh), supporting systemd services, nginx reverse proxy, Cloudflare origin pull (automatically reads cf-connecting-ip headers). It can also be run with a single uvx command or built from source.
Licensed under MIT.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.