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_'],
# Whether to unwrap prefixed parameters or not.
# Example: "utm_content" will be unwrapped into "content".
# By default - do not.
'UNWRAP_PREFIXED_PARAMETERS': False,
# 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.1]
Changed
- Make prefixed parameters unwrapping optional.
[0.1.0]
Initial version.
Metadata
Release files for wc-django-utm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| wc-django-utm-0.1.1.tar.gz | 19.1 kB | Without provenance | Details |
Release files / wc-django-utm-0.1.1.tar.gz
| Download URL | wc-django-utm-0.1.1.tar.gz |
|---|---|
| Size | 19.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d5b94a75353ef88ad294f250191928180e9f9568aa32409598d5336fae0f734a
|
|
BLAKE2b-256 checksum How to use checksums |
598f498ddc3ef286b4cce11da958edb55a0f4fa6c22ad09de78d41873af4cc17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for wc-django-utm 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.