UTM parameters tracker.
Project description
WebCase UTM tracker
Simple middleware and utils for tracking utm parameters.
Installation
pip install wc-django-utm
In settings.py
:
INSTALLED_APPS += [
'wcd_utm',
]
WCD_UTM = {
# All the "main" parameters that must be resolved.
'PARAMETERS': [
'utm_source', 'utm_medium', 'utm_campaign',
'utm_term', 'utm_content',
'gclid', 'aclk', 'msclkid', 'fbclid', 'twclid',
]),
# Additional parameter prefixes. Also used to convert prefixed parameters
# like "utm_content" into "content".
'RESOLVABLE_PREFIXES':['utm_'],
# Used to store all different utm parameters sets, that user had during the
# session.
'SESSION_STORAGE_KEY': 'utm_params_stored',
# Latest utm parameters set. The key that you are mostly going to use.
'SESSION_ACCESS_KEY': 'utm_params',
# Header to parse UTM parameters from as if it is URL.
# Use this to pass utm parameters from Android/iOS app, for example.
'HEADER_ORIGIN_URL': 'HTTP_X_UTM_ORIGIN_URL',
# Same as previous, but this one should store JSON data instead of plain
# URL string.
'HEADER_JSON': 'HTTP_X_UTM_JSON',
}
Usage
Most of the time only the middleware will be used:
MIDDLEWARE = [
# ...
'django.contrib.sessions.middleware.SessionMiddleware',
# MUST be placed after session middleware ^.
'wcd_utm.middleware.UTMSessionMiddleware',
# ...
]
In a view
Middleware will store parsed data in a SESSION_ACCESS_KEY
('utm_params'
) key. Parameter values will always be a list of strings:
def some_view(request):
params = request.session["utm_params"]
# Values are always lists
if 'black_friday_sale' in params.get('utm_campaign', []):
# Then do stuff related to you black friday sale campaign.
pass
# ...
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]
[0.1.0]
Initial version.
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
wc-django-utm-0.1.0.tar.gz
(6.6 kB
view details)
File details
Details for the file wc-django-utm-0.1.0.tar.gz
.
File metadata
- Download URL: wc-django-utm-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f73209de3233173e18ab1037ffe7b13e96762622d91bd545861c2a17f3ac1c9c |
|
MD5 | a6cc2533e5f6989bbf3f9470adf3fe52 |
|
BLAKE2b-256 | bac3982dd0fa87d3b3d6b706fcb253ad39459de7080ad35b43941b126f1916d7 |