Server side GA4 tracking
Project description
Install
pip install django-ga4-serverside
Settings
INSTALLED_APPS = [
# …
'django_ga4_serverside',
]
MIDDLEWARE = [
# …
'django_ga4_serverside.middleware.TrackingMiddleware',
]
GA4_ID = 'G-XXXXXXXXXX'
GA4_SECRET = 'XXXXXXXXXX-XXXXXXXXXXX'
GA4_DEBUG = False
Advanced settings
GA4_IGNORE_URL_REGEX - allows to configure ignored URLs
GA4_PROCESS_ANALYTICS - callback used to modify payload. Default implementation configures client_id from cookies. Default implementation:
def process_analytics(context):
client_id, created = get_or_create_client_id(context.request)
if created:
store_user_cookie(context.response, client_id)
store_parameters(context.request, client_id=client_id)
GA4_GENERATE_PAYLOAD - callback to generate payload
GA4_SHOULD_TRACK_CALLBACK - callback to filter tracked requests
API
Storing custom events
from django_ga4_serverside.utils import store_event
# inside view
store_event('custom_event', {'custom': 'property'})
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_ga4_serverside-0.0.2.tar.gz.
File metadata
- Download URL: django_ga4_serverside-0.0.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7acaa12884d05b81f93c5503fc6826ad2b97f0292a2c272e4f4a3567855da9b
|
|
| MD5 |
6265ed759431c4d010970bd8866ddb80
|
|
| BLAKE2b-256 |
15980973f95016110ddf04bb83992d30f454161750676e0c04eec0c9e987d1a4
|
File details
Details for the file django_ga4_serverside-0.0.2-py3-none-any.whl.
File metadata
- Download URL: django_ga4_serverside-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d90cb19651c1266127a34460f671a0cc65bc93e28d24f1145231e33c98a1dbab
|
|
| MD5 |
9a3179d44b3af6bf66e984cf2768a1ba
|
|
| BLAKE2b-256 |
bffe6e22a3adff365ee700d226525fdfae7568f0a1a4ea3da566a46389a6ec07
|