Skip to content
Simple Google Analytics integration for Django.
Python JavaScript
Find file
Latest commit c6c12e7 Jan 25, 2015 @rdegges Version bump.
Failed to load latest commit information.
assets Adding a simple readme purpose. Jun 25, 2012
.gitignore Adding a simple .gitignore file. Jun 25, 2012
.travis.yml Updating our travis test command, since we renamed the project. Jun 25, 2012 Bumping version. Jun 25, 2012 Fixing whitespace. Nov 7, 2014
UNLICENSE Adding UNLICENSE. Jun 25, 2012 Adding test_project for running our unit tests. Jun 25, 2012 Version bump. Jan 25, 2015


Simple Google Analytics integration for Django.


  • author: Randall Degges
  • email:
  • status: maintained, in development

Build Status


Honestly, all the other Google Analytics Django apps suck. All I want to do is put my Google Analytics code in my file, and use a simple template tag to render the Google Analytics asynchronous javascript code, damnet!

Unfortunately, all the existing solutions don't do this, and that pisses me off!


Installation and Usage

Anyway, let's install this bitch! The first thing you'll want to do is run:

$ pip install django-ganalytics

Next, modify your file, and add your Google Analytics code (usually something like UA-XXXXXXXX-XX), as well as put ganalytics in your INSTALLED_APPS:


    # ...


Now, to actually render your Google Analytics asynchronous javascript code, edit your desired Django template (I like to do this in my base.html template), and add the following:

{% load ganalytics %}
<!--- ... -->

  {% ganalytics %}

<!--- ... -->

When Django processes your template, it'll replace {% ganalytics %} with:

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', '{{ GANALYTICS_TRACKING_CODE }}', 'auto');
  ga('send', 'pageview');

Easy, right?

Something went wrong with that request. Please try again.