Simple Google Analytics integration for Django.
Project description
# django-ganalytics
Simple Google Analytics integration for Django.
## Meta
* author: Randall Degges
* email: rdegges@gmail.com
* status: maintained, in development
[![Build Status](https://secure.travis-ci.org/rdegges/django-ganalytics.png?branch=master)](http://travis-ci.org/rdegges/django-ganalytics)
## Purpose
Honestly, all the other Google Analytics Django apps suck. All I want to do is
put my Google Analytics code in my ``settings.py`` 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!
![squint](https://github.com/rdegges/django-ganalytics/raw/master/assets/squint.png)
## Installation and Usage
Anyway, let's install this bitch! The first thing you'll want to do is run:
``` bash
$ pip install django-ganalytics
```
Next, modify your ``settings.py`` file, and add your Google Analytics code
(usually something like ``UA-XXXXXXXX-XX``), as well as put
``ganalytics`` in your ``INSTALLED_APPS``:
``` python
# settings.py
INSTALLED_APPS = (
# ...
'ganalytics',
)
GANALYTICS_TRACKING_CODE = 'UA-XXXXXXXX-XX'
```
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:
``` html
{% load ganalytics %}
<!--- ... -->
<head>
{% ganalytics %}
</head>
<!--- ... -->
```
When Django processes your template, it'll replace ``{% ganalytics %}``
with:
``` html
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ GANALYTICS_TRACKING_CODE }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
```
Easy, right?
Simple Google Analytics integration for Django.
## Meta
* author: Randall Degges
* email: rdegges@gmail.com
* status: maintained, in development
[![Build Status](https://secure.travis-ci.org/rdegges/django-ganalytics.png?branch=master)](http://travis-ci.org/rdegges/django-ganalytics)
## Purpose
Honestly, all the other Google Analytics Django apps suck. All I want to do is
put my Google Analytics code in my ``settings.py`` 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!
![squint](https://github.com/rdegges/django-ganalytics/raw/master/assets/squint.png)
## Installation and Usage
Anyway, let's install this bitch! The first thing you'll want to do is run:
``` bash
$ pip install django-ganalytics
```
Next, modify your ``settings.py`` file, and add your Google Analytics code
(usually something like ``UA-XXXXXXXX-XX``), as well as put
``ganalytics`` in your ``INSTALLED_APPS``:
``` python
# settings.py
INSTALLED_APPS = (
# ...
'ganalytics',
)
GANALYTICS_TRACKING_CODE = 'UA-XXXXXXXX-XX'
```
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:
``` html
{% load ganalytics %}
<!--- ... -->
<head>
{% ganalytics %}
</head>
<!--- ... -->
```
When Django processes your template, it'll replace ``{% ganalytics %}``
with:
``` html
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ GANALYTICS_TRACKING_CODE }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
```
Easy, right?
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-ganalytics-0.1.tar.gz
(25.6 kB
view details)
File details
Details for the file django-ganalytics-0.1.tar.gz
.
File metadata
- Download URL: django-ganalytics-0.1.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18babfcf13ab825e830195ede53e0b6a98372f6d599291659367784677b69aef |
|
MD5 | fbb04c2ba779fcc2dbdc66b7bf054fce |
|
BLAKE2b-256 | eae9832855abb4f92bf9809754350ff09a9562c6261c471ef95c0ef16d3aac5a |