Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kasun/django-pixels
Tracking pixels made easy
https://github.com/kasun/django-pixels
django tracking-pixels
Last synced: 2 months ago
JSON representation
Tracking pixels made easy
- Host: GitHub
- URL: https://github.com/kasun/django-pixels
- Owner: kasun
- License: mit
- Created: 2016-12-10T10:48:09.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:29:22.000Z (about 2 years ago)
- Last Synced: 2024-11-05T17:17:31.964Z (3 months ago)
- Topics: django, tracking-pixels
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 11
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - django-pixels - Tracking pixels made easy (Python)
README
=============================
django-pixels
=============================Tracking pixels made easy. For Python 2 and Django 1.7+
Features
----------
* Built-in views to serve transparent pixels or 204 responses.
* Compose pixel tracking urls with different type IDs.
* Route tracking requests to functions using type IDs.Implementation Notes with Short Examples
----------Install django-pixels::
pip install django-pixels
Mount pixel tracking URL patterns:
.. code-block:: python
urlpatterns = [
...
url(r'^tracker/', include('django_pixels.urls', namespace="pixels")),
...
]Get the general pixel tracking url (This serves a transparent pixel as the response):
.. code-block:: python
from django.core.urlresolvers import reverse
tracking_url = reverse('pixels:pixel') # given you have mounted django_pixels urls with namespace='pixels'Get the tracking url with no-content(204) response (This serves an empty response with code 204):
.. code-block:: python
from django.core.urlresolvers import reverse
tracking_url = reverse('pixels:pixel-204') # given you have mounted django_pixels urls with namespace='pixels'Generate a pixel tracking url with type 1:
.. code-block:: python
from django_pixels import utils
utils.compose_pixel_url(tracking_url, 1)
Write a function to handle tracking calls with type 1:
.. code-block:: python
def track_emails(request):
# handle tracking with the passed HttpRequest instanceRegister the function to handle tracking calls with type 1:
.. code-block:: python
from django_pixels import handlers
handlers.register(1, track_emails)
Or mark a function to handle tracking calls with type 2:
.. code-block:: python
from django_pixels import handlers
@handlers.track(type_id=2)
def track_emails(request):
# handle tracking with the passed HttpRequest instanceSettings
----------
* PIXELS_TYPE_PARAMETER_NAME - Change the parameter name used for tracking typeCredits
-------Tools used in rendering this package:
* Cookiecutter_
* `cookiecutter-djangopackage`_.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage