klickmanufaktur/statamic-umami-analytics

Reusable Statamic control panel analytics integration for Umami.

Maintainers

Package info

github.com/klickmanufaktur/statamic-umami-analytics

Type:statamic-addon

pkg:composer/klickmanufaktur/statamic-umami-analytics

Transparency log

Statistics

Installs: 9

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.2.1 2026-07-01 12:16 UTC

This package is auto-updated.

Last update: 2026-07-01 12:16:57 UTC


README

Reusable Statamic addon for showing Umami analytics inside the control panel.

Features

  • CP navigation item with an analytics overview.
  • Read-only analytics tab on configured entry collections.
  • Server-side Umami API client with timeouts and short cache TTL.
  • Supports Umami Cloud API keys, self-hosted bearer tokens, and self-hosted username/password login.
  • {{ umami }} Antlers tag that renders the front-end tracking script.

Installation

Install as a Composer path repository while developing locally:

{
    "repositories": [
        {
            "type": "path",
            "url": "../_packages/statamic-umami-analytics",
            "options": {
                "symlink": true
            }
        }
    ],
    "require": {
        "klickmanufaktur/statamic-umami-analytics": "*"
    }
}

Then run:

composer update klickmanufaktur/statamic-umami-analytics --with-dependencies
php artisan vendor:publish --tag=statamic-umami-analytics --force

Configuration

Publish the config or set environment variables directly.

Umami Cloud

UMAMI_API_URL=https://api.umami.is/v1
UMAMI_WEBSITE_ID=00000000-0000-0000-0000-000000000000
UMAMI_AUTH=api_key
UMAMI_API_KEY=...

Self-hosted with bearer token

UMAMI_API_URL=https://umami.example.com/api
UMAMI_WEBSITE_ID=00000000-0000-0000-0000-000000000000
UMAMI_AUTH=token
UMAMI_TOKEN=...

Self-hosted with login

UMAMI_API_URL=https://umami.example.com/api
UMAMI_WEBSITE_ID=00000000-0000-0000-0000-000000000000
UMAMI_AUTH=login
UMAMI_USERNAME=...
UMAMI_PASSWORD=...

Dashboard Widget

The addon ships a compact CP dashboard widget (handle umami_analytics) showing the key metrics (page views, visitors, visits, bounce rate) plus an optional mini chart. Enable it in your app's config/statamic/cp.php under widgets:

'widgets' => [
    [
        'type' => 'umami_analytics',
        'width' => 'md',   // sm | md | lg | full
        'days' => 30,      // must be one of the configured `periods`
        'chart' => true,   // show the mini chart
        'title' => 'Analytics',
    ],
],

The widget links through to the full Umami dashboard and respects the same configuration (API credentials, periods, dashboard URL) as the rest of the addon.

Tracking Script

Add the {{ umami }} tag to your layout (e.g. right before </head>) to render the front-end tracking script:

{{ umami }}

This outputs:

<script defer src="https://umami.example.com/script.js" data-website-id="00000000-0000-0000-0000-000000000000" data-domains="example.com,www.example.com" data-performance="true" data-do-not-track="true"></script>

The script URL is derived from dashboard_url (or api_url) by default. Set UMAMI_SCRIPT_URL to override it, e.g. when the tracking script is served from a different host than the API/dashboard.

Tracker attributes

Configure the data-* behaviour flags under tracking (see tracker configuration):

Important

Auto-derivation reads that environment's own app.url, so a staging deployment would allow-list its own staging host and track itself. If staging/preview environments exist, set UMAMI_TRACKING_DOMAINS explicitly to the production domain in every environment's .env (not just production) so only hits from the real domain are ever recorded.

# Restrict the tracker to these hostnames (comma-separated). Leave unset to
# derive "host,www.host" from app.url, or set to "false" to disable.
UMAMI_TRACKING_DOMAINS=

# Collect Core Web Vitals (default: true).
UMAMI_TRACKING_PERFORMANCE=true

# Honour the visitor's browser "Do Not Track" setting (default: true).
UMAMI_TRACKING_DO_NOT_TRACK=true

Entry Tab

By default, the addon injects a Zugriffe tab into the pages collection.

'entry_tab' => [
    'enabled' => true,
    'collections' => ['pages', 'news'],
    'tab' => 'analytics',
    'display' => 'Zugriffe',
    'field' => 'umami_analytics',
],