Skip to main content
# django-ganalytics

Simple Google Analytics integration for Django.


## Meta

* author: Randall Degges
* email: r@rdegges.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>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', '{{ GANALYTICS_TRACKING_CODE }}', 'auto');
ga('send', 'pageview');
</script>
```

Easy, right?


Metadata

Release files for django-ganalytics 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-ganalytics 0.7.0
File Size Uploaded Provenance Actions
django-ganalytics-0.7.0.tar.gz 26.2 kB Without provenance Details for django-ganalytics-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-ganalytics 0.7.0
File Interpreter ABI Platform Actions
django_ganalytics-0.7.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for django_ganalytics-0.7.0-py2.py3-none-any.whl

Total release size: 32.4 kB

Release files / django-ganalytics-0.7.0.tar.gz

Download URL django-ganalytics-0.7.0.tar.gz
Size 26.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d0ff1bf7be452b76e9117427a09f00bc9bcf75c2dada0837673142e3e850b6fa
BLAKE2b-256 checksum
How to use checksums
231856d619e5de754eb2aaa79a62ebdba3f273bf71191e6d806864914f852208
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_ganalytics-0.7.0-py2.py3-none-any.whl

Download URL django_ganalytics-0.7.0-py2.py3-none-any.whl
Size 6.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c4ecefb6a70a90fd18f155235b6f14f1a9af5819dc804b46d16030863e03a746
BLAKE2b-256 checksum
How to use checksums
c2a937803f7654515ef725f33bedc92478a48b13db2cdbf3669b68f2693814d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-ganalytics 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page