This django app enables server side traffic tracking. The code is greatly inspired by the Django Google Analytics app.
- Install
django-matomo-api-tracking
from pypi usingpip install django-matomo-api-tracking
-
add
matomo_api_tracking
to yourINSTALLED_APPS
setting. -
add a new variable
MATOMO_API_TRACKING
to your settings to configure the behaviour of the app:MATOMO_API_TRACKING = { 'url': 'https://your-matomo-server.com/matomo.php', 'site_id': <your_site_id>, # 'ignore_paths': ["/debug/", "/health/"], # 'token_auth': "", # e.g. "33dc3f2536d3025974cccb4b4d2d98f4" }
-
enable the middleware by adding the matomo_api_tracking middleware to the list of enabled middlewares in the settings:
MIDDLEWARE = [ ... 'matomo_api_tracking.middleware.MatomoApiTrackingMiddleware', ]
In the settings part, the ignore_path
can be used to entirely skip certain
paths from being tracked. If you specify an token_auth
, the app will also send
the client's IP address (cip parameter). But this is not required.