Giter Club home page Giter Club logo

django-referer's Introduction

django-referer

django-referer is a Django app for displaying different referer details based on a customizable query parameter and keeping this query parameter while user navigates in the site.
It provides sales, partners and affiliates custom links to send out in order to get private traffic. It gives sales, partners and affiliates their opportunity to convert every contact detail on the website to their own. It thus encourages sales, partners and affiliates to promote the website and the business. In addition, with the help of analytics scripts, traffic data can be easily distinguished and analyzed.

Demo

  1. URL with referer parameter e.g. https://zhujia.com.au/?refer=14

django-referer Demo - Link with referer (The chosen query parameter is kept by django-referer's middleware while user navigates between links) django-referer Demo 2 - Link with referer

  1. URL without referer parameter (falls back to the default referer) e.g. https://zhujia.com.au

django-referer Demo - Link without referer django-referer Demo 2 - Link without referer

Installation

Use the package manager pip to install django-referer.

pip install django-referer

Usage

Step 1. Add referer middleware (in settings.py file)

MIDDLEWARE = [
    'referer.middleware.referer.RefererMiddleware',  # here 
    'django.middleware.security.SecurityMiddleware',
    '...'
]

Step 2. Add referer context processor (in settings.py file)

TEMPLATES = [
    {
        'OPTIONS': {
            'context_processors': [
                '...',
                'django.contrib.messages.context_processors.messages',
                'referer.context_processors.referer',  # here
            ],
        },
    },
]

Step 3. Customize referer settings (in settings.py file) (optional)

The defaults are:

REFERER_LINK_PARAMETER = 'referer'
REFERER_DEFAULT_ID = 1
# -> ?referer=1

REFERER_MODEL_FROM = 'django.contrib.auth.models'
REFERER_MODEL_IMPORT = 'User'
# -> from REFERER_MODEL_FROM import REFERER_MODEL_IMPORT

REFERER_IGNORED_LINKS = []

Step 4. Display referer information (in .html file)

<a href="mailto:{{ referer.email }}">Email</a>
<p>{{ referer.first_name }} {{ referer.last_name }}</p>

Contributing

Issues and pull requests are welcomed.

License

MIT ยฉ Yifan Ai

django-referer's People

Contributors

yifaneye avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.