Skip to content
This repository has been archived by the owner on Sep 13, 2018. It is now read-only.

rwanyoike/django-ganalytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django GAnalytics

This project is a simple integration of the Google Analytics tracking code for quick implementation in Django projects.

Requirements

  • Python 2.5+
  • Django 1.4+

Installation

  1. Add the ganalytics directory to your Python path.
  2. Add ganalytics to your INSTALLED_APPS setting:

    INSTALLED_APPS = (
        ...
        'ganalytics',
    )

Configuration

  1. The ganalytics_load template tag requires a tracking_id and site_domain. You must either pass them as arguments or set GOOGLE_ANALYTICS_PROPERTY_ID and GOOGLE_ANALYTICS_SITE_DOMAIN in your settings. Setting this value means that you can omit the tracking_id and site_domain arguments when invoking the template tag.

Basic Usage

  1. Load the tag library:

    {% load ganalytics %}
  2. Load the js tracking code:

    {% ganalytics_load tracking_id=XXXXXXXXX site_domain=XXXXXXXXX %}

    or with GOOGLE_ANALYTICS_PROPERTY_ID and GOOGLE_ANALYTICS_SITE_DOMAIN defined in settings.py:

    {% ganalytics_load %}

Example

{% load ganalytics %}

<html>
  <head>
    <title>Full Example</title>
    {% ganalytics_load %}
  </head>
  <body>
    ...
  </body>
</html>

Note

django-ganalytics uses the Universal Analytics tracking method (not the Classic Analytics) for the code.