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
Install or add django-google-analytics to your Python path.
Add google_analytics to you INSTALLED_APPS setting.
Add URL include to your project’s urls.py file:
(r'^djga/', include('google_analytics.urls')),
Specify a Google Analytics tracking code, i.e.:
GOOGLE_ANALYTICS = { 'google_analytics_id': 'xxx', }
where xxx is your tracking code.
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/', ]
Changelog
2.1.6
Fix encoding for title
2.1.5
Fix encoding in URL
2.1.4
get language from request utils.py
2.1.3
fix header name for Accepts-Language in tasks.py
2.1.2
ensure we fill in the page title if it’s available
2.1.1
bug - build_ga_params expects account to be supplied
replace httplib2 with requests
2.1.0
Allow uip to be overriden using custom header
2.0.3
Use x-forwarded-for for ip address
2.0.2
Django 1.6 not required
2.0.1
Use correct URL for GA Measurement Protocol v1
2.0.0
Upgrade to GA Measurement Protocol v1
1.0.0
Make compatible with Django 1.6
0.0.5
Removed Jmbo dependency, renamed.
0.0.4
Better packaging.
0.0.3
Fork, rename, re-license from panomena-analytics.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-google-analytics-app-2.1.6.tar.gz
.
File metadata
- Download URL: django-google-analytics-app-2.1.6.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04b995fa5f2a062b7a770bcb64e7f06c5402b6e85a6af95e5d9bac07c88c5140 |
|
MD5 | 6ee2cb3ec4f0056e01ccb33093479742 |
|
BLAKE2b-256 | 637b0c3d1f34a7b6b12d38fe2a7b9247f4c88c238dc3734c9cd7b389cb6a4779 |