Skip to main content

Django Google Analytics app allowing for server side/non-js tracking.

Project description

Django Google Analytics

Django Google Analytics brings the power of server side/non-js Google Analytics to your Django projects

Installation

  1. Install or add django-google-analytics to your Python path.

  2. Add google_analytics to you INSTALLED_APPS setting.

  3. Add URL include to your project’s urls.py file:

    (r'^djga/', include('google_analytics.urls')),
  4. Specify a Google Analytics tracking code, i.e.:

    GOOGLE_ANALYTICS = {
        'google_analytics_id': 'xxx',
    }

    where xxx is your tracking code.

  5. If you intend tracking through middleware and Celery remember to install Celery and run its worker process.

Usage

There are two ways to add tracking to your pages.

1. HTML tag

Using <img/> and sticking it in your base.html:

{% load google_analytics_tags %}
<div style="display:none">
    <img src="{% google_analytics %}" width="0" height="0" />
</div>

2. Middleware + Celery

Using Django’s middleware, you can process every request and use Celery to make the request to Google Analytics:

MIDDLEWARE_CLASSES = (
    'google_analytics.middleware.GoogleAnalyticsMiddleware',
)

You have to add google_analytics to your CELERY_IMPORTS:

CELERY_IMPORTS = ('google_analytics.tasks')

You can also specify paths that will be excluded when tracking:

GOOGLE_ANALYTICS_IGNORE_PATH = ['/health/', ]

Authors

Praekelt Foundation

  • Hedley Roos

  • Milton Tony

  • Shaun Sephton

Unomena

  • Euan Jonker

Changelog

0.0.5

  1. Removed Jmbo dependency, renamed.

0.0.4

  1. Better packaging.

0.0.3

  1. Fork, rename, re-license from panomena-analytics.

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-google-analytics-app-0.0.5.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

django_google_analytics_app-0.0.5-py2.7.egg (15.7 kB view details)

Uploaded Source

File details

Details for the file django-google-analytics-app-0.0.5.tar.gz.

File metadata

File hashes

Hashes for django-google-analytics-app-0.0.5.tar.gz
Algorithm Hash digest
SHA256 f398924ce93843c50576df685f4314f559ac4ec5b766be7ba5c26c3a1e99d00b
MD5 b31ab904a940881c38ec0fa2e08d5755
BLAKE2b-256 4c50382eb4e06a9af29a1c7d78e8482f9b5da3b259af3f3925cfb7120c878cae

See more details on using hashes here.

File details

Details for the file django_google_analytics_app-0.0.5-py2.7.egg.

File metadata

File hashes

Hashes for django_google_analytics_app-0.0.5-py2.7.egg
Algorithm Hash digest
SHA256 4438b83b9047b6c4035c03fbc8bfd46459717b6ff5eb6ca70b156c94cc8d45a0
MD5 82a25fcbed1d232a2933a8df2dec6377
BLAKE2b-256 1a960f6d30e8735d52236aaeb5616ec419e9f942e0765a49e87955bd5d313695

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page