Skip to main content

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 your INSTALLED_APPS setting.

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

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

    GOOGLE_ANALYTICS = {
        'google_analytics_id': 'UA-000000-2',
    }

    where UA-000000-2 is your unique 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 = [
    '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/', ]

Release files for django-google-analytics-app 6.0.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-google-analytics-app 6.0.0
File Size Uploaded
django-google-analytics-app-6.0.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-google-analytics-app 6.0.0
File Interpreter ABI Platform
django_google_analytics_app-6.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 26.3 kB

Release files / django-google-analytics-app-6.0.0.tar.gz

Download URL django-google-analytics-app-6.0.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
88fb1a057182e0aad5a653717a44f8880c8916d6b606b2f625309fde3afb1e02
BLAKE2b-256 checksum
How to use checksums
43c3887ba3e7806cec2596bd723c42f3efc372398f5e544e9f76a5ff283d00b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / django_google_analytics_app-6.0.0-py2.py3-none-any.whl

Download URL django_google_analytics_app-6.0.0-py2.py3-none-any.whl
Size 13.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
badefb910a46f09040ab24f652497a58adcae07ca1526869cd34ee8632fce729
BLAKE2b-256 checksum
How to use checksums
7fcc45f30eddd0a4e2eaacab22149858c4b6c39d3ef90bd05e0dce0f1358e6d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

6.0.0 This release

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.4.2

2 release files

4.4.1

2 release files

4.4.0

2 release files

4.3.10

2 release files

4.3.9

2 release files

4.3.7

2 release files

4.3.6

2 release files

4.3.5

2 release files

4.3.4

2 release files

4.3.3

2 release files

4.3.2

2 release files

4.3.1

2 release files

4.3.0

1 release file

4.2.0

1 release file

4.1.0

1 release file

4.0.0

1 release file

3.0.0

1 release file

2.1.6

1 release file

2.1.5

1 release file

2.1.4

1 release file

2.1.3

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.0

1 release file

0.0.5

2 release files

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