Skip to main content

django-basic-stats is a simple traffic statistics application. It show latest referrer, google queried terms or overall hits count.

It also provides optional logging and statistics for mobile devices (user agent, screen and window width/height, device pixel ratio).

Installation

  • Run pip install django-basic-stats

  • Add ‘stats’, to INSTALLED_APPS

  • Add ‘stats.middleware.StatsMiddleware’ to MIDDLEWARE_CLASSES

  • Add url(r’^stats/’, include(‘stats.urls’)) to your urlpatterns in urls.py

  • Run “python manage.py migrate” to sync the database

Enabling mobile device logging

Mobile devices are logged via JavaScript code sending AJAX requests if browser USER AGENT matches one of mobile devices.

Assuming you have jQuery available you will have to add such JavaScript code to you site:

var ismobile = (/iphone|ipod|android|blackberry|mini|palm|smartphone|ipad|xoom|playbook|tablet|mobile|kindle/i.test(navigator.userAgent.toLowerCase()));
if (ismobile) {
    $(document).ready(function(){
        $.ajax({
        url: '/stats/mobile/',
        cache: false,
        type: "GET",
        data: {"window_width": window.innerWidth,
        "window_height": window.innerHeight,
        "screen_width": screen.width,
        "screen_height": screen.height,
        "device_pixel_ratio": window.devicePixelRatio},
        });
    });
}

If you are using other JavaScript library you will have to redo the AJAX sending part. Note that /stats/mobile/ is a hardcoded URL.

Usage

Statistics are visible for site staff. Login to you site as such user and go to /stats/

In Django admin panel you will also get “Mobile” model with all logged mobile devices.

Metadata

Release files for django-basic-stats 0.2.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-basic-stats 0.2.0
File Size Uploaded Provenance
django-basic-stats-0.2.0.tar.gz 7.2 kB Without provenance Details

Release files / django-basic-stats-0.2.0.tar.gz

Download URL django-basic-stats-0.2.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
af2bcdfcf519b0bd6f7bdc460c510f88b5c94557483303bc4252352af9b68acc
BLAKE2b-256 checksum
How to use checksums
341e9e82dfca67eefb03d4f55efe355a42a18d0dafc76402514ab1f1300ccd8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-basic-stats 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file No provenance

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