This project is a simple integration of the Google Analytics tracking code for quick implementation in Django projects.
- Python 2.5+
- Django 1.4+
- Add the
ganalytics
directory to your Python path. Add
ganalytics
to yourINSTALLED_APPS
setting:INSTALLED_APPS = ( ... 'ganalytics', )
- The
ganalytics_load
template tag requires atracking_id
andsite_domain
. You must either pass them as arguments or setGOOGLE_ANALYTICS_PROPERTY_ID
andGOOGLE_ANALYTICS_SITE_DOMAIN
in your settings. Setting this value means that you can omit thetracking_id
andsite_domain
arguments when invoking the template tag.
Load the tag library:
{% load ganalytics %}
Load the js tracking code:
{% ganalytics_load tracking_id=XXXXXXXXX site_domain=XXXXXXXXX %}
or with
GOOGLE_ANALYTICS_PROPERTY_ID
andGOOGLE_ANALYTICS_SITE_DOMAIN
defined in settings.py:{% ganalytics_load %}
{% load ganalytics %}
<html>
<head>
<title>Full Example</title>
{% ganalytics_load %}
</head>
<body>
...
</body>
</html>
django-ganalytics
uses the Universal Analytics tracking method (not the Classic Analytics) for the code.