PHPackages                             oliweb/statamic-privacy-analytics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. oliweb/statamic-privacy-analytics

ActiveStatamic-addon[Caching](/categories/caching)

oliweb/statamic-privacy-analytics
=================================

A powerful, efficient analytics solution for Statamic with real-time tracking, caching, and comprehensive dashboard visualization.

v1.2.6(1mo ago)026↓83.3%MITPHPPHP ^8.3

Since Jan 12Pushed 2w agoCompare

[ Source](https://github.com/oliweb-ch/statamic-privacy-analytics)[ Packagist](https://packagist.org/packages/oliweb/statamic-privacy-analytics)[ RSS](/packages/oliweb-statamic-privacy-analytics/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (5)Dependencies (6)Versions (28)Used By (0)

Privacy Analytics for Statamic
==============================

[](#privacy-analytics-for-statamic)

A self-hosted, privacy-first analytics addon for Statamic. No Google. No third-party scripts. No cookies by default. Your data stays on your server.

> Fork of [mohammedshuaau/enhanced-analytics](https://github.com/mohammedshuaau/enhanced-analytics) — significantly extended and refactored.

Why this addon?
---------------

[](#why-this-addon)

- **Zero external tracking dependencies** — no Google Analytics, no Matomo cloud, no Plausible cloud
- **Direct DB writes** — every page view is recorded instantly, no processing queue needed for real-time data
- **GDPR-ready** — built-in consent banner with granular controls (optional)
- **Self-hosted geolocation** — IP → country/city via [ip-api.com](https://ip-api.com) with local caching, no Google Maps

---

Features
--------

[](#features)

### Dashboard

[](#dashboard)

- Date ranges : 24h, 7 days, 30 days, custom
- Comparison with previous period (visits, unique visitors, bounce rate)
- CSV export
- Auto-refresh (configurable interval)
- Dark mode support

### Widgets

[](#widgets)

WidgetDescriptionOverviewTotal visits, unique visitors, avg. time on site, bounce rateVisit frequencyNew vs returning, pages/session, avg. session durationPage views over timeLine chart, total + unique views per dayTop countriesBar chart + table with % of totalDevice typesDoughnut chart (desktop / mobile / tablet)Browser usageDoughnut chart**Traffic sources**Direct / Search / Social / Referral + top referring domains**Platforms / OS**Horizontal bar chart**Top cities**Table with progress bars**Activity heatmap**7-day × 24-hour CSS grid, intensity-based coloring**Real-time visitors**Active sessions/visitors in the last 5 / 15 / 30 min, auto-refresh every 30s**New vs returning trend**Stacked area chart over the selected period**Session depth**Page distribution per session (1 / 2-3 / 4-5 / 6-10 / 10+)Page performanceTop 10 pages: views, unique views, avg. time, bounce rate, exit rateUser flowEntry pages, most engaged pages, exit pages### Privacy &amp; tracking

[](#privacy--tracking)

- Consent banner (disabled by default) with granular controls
- Bot filtering
- Configurable excluded paths and IPs
- Optional authenticated user tracking
- Geolocation optional per-visitor via consent settings

---

Requirements
------------

[](#requirements)

- PHP ≥ 8.3
- Statamic ≥ 6.0
- MariaDB / MySQL

---

Installation
------------

[](#installation)

```
composer require oliweb/statamic-privacy-analytics
```

Publish the configuration:

```
php artisan vendor:publish --tag=statamic-analytics-config
```

Run the migrations:

```
php artisan migrate
```

The addon starts tracking immediately. Access the dashboard via **Control Panel → Tools → Analytics**.

---

Configuration
-------------

[](#configuration)

`config/statamic-analytics.php` :

```
return [
    'geolocation' => [
        'cache_duration' => 1440, // minutes (24h)
        'rate_limit'     => 45,   // requests per minute (ip-api.com free tier)
    ],

    'processing' => [
        'frequency'    => 15, // minutes — aggregate recalculation frequency
        'lock_timeout' => 60,
    ],

    'dashboard' => [
        'refresh_interval' => 300, // seconds
    ],

    'tracking' => [
        'exclude_paths' => ['cp/*', 'api/*'],
        'exclude_ips'   => [],
        'exclude_bots'  => true,
        'track_authenticated_users' => true,
        'consent' => [
            'enabled' => false, // set to true to require visitor consent
            'banner'  => [
                'title'          => 'Privacy Notice',
                'description'    => 'We use analytics to understand how visitors use our site.',
                'accept_button'  => 'Accept',
                'decline_button' => 'Decline',
                'settings_button'=> 'Customize',
                'position'       => 'bottom', // bottom | top | center
            ],
        ],
    ],
];
```

---

Consent banner
--------------

[](#consent-banner)

When `tracking.consent.enabled` is `true`, tracking only starts after visitor consent.

Add to your Antlers layout:

```
{{ statamic_analytics:consent_banner }}

```

Publish and customize the template:

```
php artisan vendor:publish --tag=statamic-analytics-views
```

Template location after publishing:

```
resources/views/vendor/statamic-analytics/components/consent-banner.antlers.html

```

---

Aggregate recalculation
-----------------------

[](#aggregate-recalculation)

The addon writes page views directly to the database on every request. A scheduled command recalculates aggregates (by country, device, browser, platform) for today and yesterday:

```
php artisan analytics:process
```

This runs automatically via Laravel Scheduler at the frequency defined in config. Make sure the scheduler is running:

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

---

Architecture
------------

[](#architecture)

```
HTTP request
    └─ TrackPageVisit middleware
           └─ INSERT into statamic_analytics_page_views   ← direct, real-time

Scheduler (every N minutes)
    └─ analytics:process
           └─ DELETE + INSERT into statamic_analytics_aggregates
              (recalculated from page_views for today + yesterday)

```

Geolocation (IP → country/city) is resolved via ip-api.com and cached locally. No data is sent to Google or any tracking platform.

---

License
-------

[](#license)

MIT — see [LICENSE.md](LICENSE.md).

Original work © 2024 Mohammed Shuaau. Modifications © 2026 Olivier Petrucciani (OliWeb - oliweb.ch).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~5 days

Total

27

Last Release

39d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/48fcf1e2370bf67b2856e949261d339ac202fd5cc67235225f9297bd39faef84?d=identicon)[oliweb](/maintainers/oliweb)

---

Top Contributors

[![oli217](https://avatars.githubusercontent.com/u/83109898?v=4)](https://github.com/oli217 "oli217 (2 commits)")

---

Tags

analyticsgdprprivacystatamicstatamic-addonperformancereal-timetrackingcachedashboardanalyticschartchartjsstatamicalpinejsEnhancedStatamic addonstatamic-analytics

### Embed Badge

![Health badge](/badges/oliweb-statamic-privacy-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/oliweb-statamic-privacy-analytics/health.svg)](https://phpackages.com/packages/oliweb-statamic-privacy-analytics)
```

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[putyourlightson/craft-blitz

Intelligent static page caching for creating lightning-fast sites.

155484.7k37](/packages/putyourlightson-craft-blitz)[muhammadsadeeq/laravel-activitylog-ui

A beautiful, modern UI for Spatie's Activity Log with advanced filtering, analytics, and real-time features.

17717.0k](/packages/muhammadsadeeq-laravel-activitylog-ui)[anahkiasen/flatten

A package for the Illuminate framework that flattens pages to plain HTML

33313.0k](/packages/anahkiasen-flatten)[silverstripe/staticpublishqueue

Static publishing queue to create static versions of pages for enhanced performance and security

44140.1k6](/packages/silverstripe-staticpublishqueue)[maartenstaa/laravel-41-route-caching

This package allows you to cache your routes definitions, thereby speeding up each request.

25381.4k](/packages/maartenstaa-laravel-41-route-caching)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
