Skip to main content

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

Project description

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

Installation

  1. Install django-google-analytics-app from PyPI or add to your Python path some other way.

  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/', ]

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-4.3.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

django_google_analytics_app-4.3.4-py2.py3-none-any.whl (11.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: django-google-analytics-app-4.3.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for django-google-analytics-app-4.3.4.tar.gz
Algorithm Hash digest
SHA256 1df8c7035339d15b94c057b2fc7eb1c944e38e3fb21122bb0130fedaa65004e5
MD5 285747c898e4104a7fc6bf5ef8ec9dff
BLAKE2b-256 da1de74e61323d44416dec998b77af0392df58d4168a69763a7a8481d4b85b2d

See more details on using hashes here.

File details

Details for the file django_google_analytics_app-4.3.4-py2.py3-none-any.whl.

File metadata

  • Download URL: django_google_analytics_app-4.3.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for django_google_analytics_app-4.3.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7f1a89dbfb21a34f07cec742c9ecd017df3d5fe7502595b7ef68649597c9483d
MD5 e1b47dd9ea449745037a411d6520ead2
BLAKE2b-256 75a1f63965ce361d445813c2f4168bc907f8847ddcba69375a18a29119c04a9a

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