http://github.com/idlesign/django-sitemetrics
Reusable application for Django providing easy means to integrate site metrics counters into your sites
Yandex Metrika - http://metrika.yandex.ru/
Provider alias: yandex
Google Analytics - http://www.google.com/analytics/
Provider alias: google
Openstat - https://www.openstat.com/
Provider alias: openstat
- Add the
sitemetricsapplication toINSTALLED_APPSin your settings file (usuallysettings.py) - Add
{% load sitemetrics %}tag to the top of a template (usually base template, e.g._base.html)
Then you have two options to add metrics counter code to your page:
Use
four argumentssitemetrics tag notation:{% sitemetrics by google for "UA-000000-0" %}
Here:
googleis a metrics provider alias;UA-000000-0- metrics counter keycode.That is how you put Google Analytics counter code (with
UA-000000-0keycode) into page.Use
no argumentssitemetrics tag notation:{% sitemetrics %}
That is how you put all counter 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 contribs are required for this approach to work.
Use
./manage.py migrateto install sitemetrics tables into your database.