django-external-urls

Track external links with a signal on click.


Keywords
django, external, url, redirect
License
BSD-3-Clause
Install
pip install django-external-urls==0.3

Documentation

django-external-urls

Captures clicks on external links, and invokes a callback (signal).

Useful for tracking outbound links.

pip install django-external-urls

Settings:

Add to settings.py:

INSTALLED_APPS = (
    'external_urls',
)

Add to url.py:

urlpatterns = patterns('',
    url(r'', include('external_urls.urls')),
)

Usage:

  1. The templates can be used as follows:

    {% load external_urls %}
    {% external_url object.website %}
    {% external_url "http://example.com/" %}
    
  2. Sends a Signal, external_link:

    from external_links.signals import external_click
    from django.dispatch import receiver
    
    @receiver(external_click)
    def my_callback(sender, url, ip):
        print("tracked click to {} from {}".format(url, ip))