Django Google Analytics app allowing for server side/non-js tracking.
Project description
Django Google Analytics brings the power of server side/non-js Google Analytics to your Django projects
Installation
Install django-google-analytics-app from PyPI or add to your Python path some other way.
Add google_analytics to your INSTALLED_APPS setting.
Add URL include to your project’s urls.py file:
re_path('djga/', include('google_analytics.urls')),
Specify a Google Analytics tracking code, i.e.:
GOOGLE_ANALYTICS = { 'google_analytics_id': 'UA-000000-2', }
where UA-000000-2 is your unique tracking code.
If you intend tracking through middleware and Celery remember to install Celery and run its worker process.
Usage
There are two ways to add tracking to your pages.
1. HTML tag
Using <img/> and sticking it in your base.html:
{% load google_analytics_tags %} <div style="display:none"> <img src="{% google_analytics %}" width="0" height="0" /> </div>
2. Middleware + Celery
Using Django’s middleware, you can process every request and use Celery to make the request to Google Analytics:
MIDDLEWARE = [ 'google_analytics.middleware.GoogleAnalyticsMiddleware', ]
You have to add google_analytics to your CELERY_IMPORTS:
CELERY_IMPORTS = ('google_analytics.tasks')
You can also specify paths that will be excluded when tracking:
GOOGLE_ANALYTICS_IGNORE_PATH = ['/health/', ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-google-analytics-app-5.0.5.tar.gz
.
File metadata
- Download URL: django-google-analytics-app-5.0.5.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63dfd6a9700ac91b7994ade300018b12321b958949c3f63ccbffd2732354b62b |
|
MD5 | dcef954d90faa183d6e0b96c835b1e87 |
|
BLAKE2b-256 | a63743fbb54cdc665b9782797a69e6533222bc189a02c3d935b62f5c1d706b0e |
File details
Details for the file django_google_analytics_app-5.0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: django_google_analytics_app-5.0.5-py2.py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef1d565b7f22c856c646892b871bb5a399762d1ba7eb9041c977340d531f766a |
|
MD5 | 6ca6e714dff0ac6a46b6c28bfaf9926a |
|
BLAKE2b-256 | 75bf1acc3f03d188cc9dcf0075d9015cad1c0440755a8e5783e1b6103dbe7ebf |