Skip to main content

This reusable Django app can help you to site metrics (Yandex Metrika, Google Analytics)

Project description

http://github.com/idlesign/django-sitemetrics

What’s that

django-sitemetrics is a reusable application for Django 1.1+ that offers easy integration with different site metrics service providers.

Currently supported site metrics providers

  1. Yandex Metrikahttp://metrika.yandex.ru/

Provider alias: ‘yandex’

  1. Google Analyticshttp://www.google.com/analytics/

Provider alias: ‘google’

How to use

  1. Add the ‘sitemetrics’ application to ‘INSTALLED_APPS’ in your settings file (usually ‘settings.py’)

  2. Add ‘{% load sitemetrics %}’ tag to the top of a template (usually base template, e.g. ‘base.html’)

Then you have two options that add metrics client code to your page:

  • Use so-called ‘four arguments’ sitemetrics tag notation:

    {% sitemetrics by google for "UA-000000-0" %}

    Here: ‘google’ — provider alias; ‘UA-000000-0’ — keycode argument. That’s how you put Google Analytics client code (with ‘UA-000000-0’ keycode) into page.

  • Use so-called ‘no arguments’ sitemetrics tag notation:

    {% sitemetrics %}

    That’s how you put all client codes registered and active for the current site.

    Client codes are registered with sites through Django Admin site interface.
    Admin site’ and ‘Sites’ from Django contrib are required for this option to work.
    ./manage.py syncdb’ is required just once for this option to work (it installs sitemetrics table into database).

How to add site metrics providers

  1. Edit ‘sitemetrics/models.py’. Add new provider alias and name into KEYCODE_PROVIDERS list.

  2. Edit ‘sitemetrics/templates/sitemetrics/sitemetrics.tpl’. Add another ‘ifequal’ clause with ‘keycode.provider’ check against the alias of your new provider.

Translating django-sitemetrics

You can translate application into your language if it is supported by Django.
For translation tips refer to Django documentation: http://docs.djangoproject.com/en/1.1/topics/i18n/localization/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sitemetrics-0.2.tar.gz (7.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page