Smart, privacy-friendly site analytics for Django. Track visits, popular pages, referrers, and more — directly from the admin dashboard.
- 🔒 Privacy-Focused: Designed with user privacy in mind.
- 🛠️ Admin Dashboard Integration : View analytics directly within Django's admin interface.
- 📈 Page Tracking: Monitor page visits and identify popular content.
- 🔗 Referrer Tracking: Understand where your traffic is coming from.
- 🎨 Customizable: Easily extend and modify to fit your project's needs.
- 🔗 Add a referral system
- ⚡ Reduce logging load in
VisitLog
- 🔍 Add filters in the admin panel
- 📚 Implement documentation
-
Install the package via pip:
pip install django-sightline
-
Add
'sightline'
to yourINSTALLED_APPS
insettings.py
:INSTALLED_APPS = [ ... 'sightline', ... ]
-
Run migrations to set up the necessary database tables:
python manage.py migrate sightline
-
Include the middlewares you need in your
MIDDLEWARE
settings:MIDDLEWARE = [ ... 'sightline.middleware.VisitLogMiddleware', ... ]
-
Optionally, configure the
SIGHTLINE_SETTINGS
dicts to customize your tracking experience:SIGHTLINE_SETTINGS = { "visit": { "enabled": True, "exclude_path": r"^/admin/", "interval_capturing": 5 # Seconds }, "geoip": { "enabled": False, "marker_interval": 10 # days } }
Once installed, django-sightline automatically tracks page visits and referrers. You can view the analytics data in the Django admin interface under the "Sightline" section.
To customize the behavior, you can extend the provided models and middleware. For example, to track additional data or modify the tracking logic, customize your Admin Model with BaseLogAdmin
and override the methods and criteria for metrics generation.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.