Skip to content

Middleware

Setup

Add "django_umami.middleware.TrackAllViewsMiddleware" to your django settings. Example below.

Example
MIDDLEWARE = [
    "django.middleware.security.SecurityMiddleware",
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.middleware.common.CommonMiddleware",
    "django.middleware.csrf.CsrfViewMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
    "django_umami.middleware.TrackAllViewsMiddleware" ## ADD THIS LINE
]

And that's it! You are now tracking all views automatically.

Be aware, this may cause extra latency between requests especially if your django server location is far away from the Umami server location.

Settings

Of course, we allow you to modify who you want to track :)

OPTION - Filter static

Filter static

Setting this to True will block out all requests made to static sources. By default, this is enabled.

from django_umami.core import umami

umami.options.filter_static = True

OPTION - Filter media

Filter media

Setting this to True will block out all requests made to media sources such as user profile pictures. By default, this is enabled.

from django_umami.core import umami

umami.options.filter_media = True

OPTION - Filter anonymous

Filter anonymous

Setting this to True will block out all requests made from unauthenticated users. By default, this is disabled and all visits will be tracked.

from django_umami.core import umami

umami.options.filter_anonymous = True

OPTION - Filter superuser

Filter superuser

Setting this to True will block out all requests made by super users. By default, this is enabled.

from django_umami.core import umami

umami.options.filter_superusers = True

OPTION - Filter admin pages

Filter admin pages

Setting this to True will block out all requests made to /admin pages. By default, this is disabled.

from django_umami.core import umami

umami.options.admin_pages = True

OPTION - Filter custom pages (by path)

Filter custom pages by path

Adding a path to this list will block all tracking for it.

from django_umami.core import umami

umami.options.filter_page_paths.append("/dashboard/")

OPTION - Filter custom pages (by URL name)

Filter custom pages by URL name

Adding a URL Name (name="blah" in urls) to this list will block all tracking for it.

from django_umami.core import umami

umami.options.filter_page_url_names.append("dashboard")