arnoson / kirby-stats

Simple and privacy friendly web statistics for Kirby CMS.
MIT License
8 stars 0 forks source link

Kirby Stats

:warning: This plugin is still in alpha, a lot of features are still missing or not completed yet.

Kirby stats is a simple, privacy friendly Kirby 3 plugin for tracking page views and visits.

Kirby Stats Panel Screenshot

Note

I'm no lawyer and can't give you any legal advice regarding GDPR. I can only tell you what data the plugin is collecting. For each page view various counters are increased for a specified time interval. For example, after the first user has visited your website the data would be:

path time views visits Firefox Windows
/ unixtimestamp 1 1 1 1

That's it. No IP address is stored and no cookie is set by this plugin. And also no unique requests, all data is grouped into time intervals. If a second user visits in the same hour, the counters are increased accordingly. If a user visits in the following hour or later a new row of counters is created in the table.

Please checkout the source code and decide for yourself what this means for your privacy statement and GDPR.

Installation

composer require arnoson/kirby-stats

Usage

Also see the /example folder, documentation is still WIP.

The plugin provides an endpoint /kirby-stats/hit which gets called from a little script. Simply add the script to your website and include it in your templates like shown in the example.

Options

// site/config.php
[
  'arnoson.kirby-stats' => [
    // Enable or disable tracking. This is useful to disable tracking in local
    // development by using Kirby's multi environment config setup:
    // https://getkirby.com/docs/guide/configuration#multi-environment-setup
    'enabled' => true,

    // The time interval in which to group the collected data. Use the default
    // 'hour' if you are interested in how your visits/views change during the
    // day, or something like 'week' if don't really care about the details.
    // Allowed values: 'hour', 'day', 'week', 'month', 'year'.
    'interval' => 'hour',

    // Where to (automatically) create the database. Default is
    // '/storage/stats.sqlite' for public folder setups or
    // '/site/storage/stats.sqlite' for normal setups.
    'sqlite' => dirname(__DIR__) . '/some-file-path.sqlite',
  ],
];

Note: if you want to use Kirby's roots to define the database location use Kirby's ready callback:

[
  'ready' => fn() => [
    'arnoson.kirby-stats.sqlite' => kirby()->root('site') . '/stats.sqlite',
  ],
];

Credits