A tiny plugin for local traffic analytics in Kirby CMS.
Kirby tracking uses javascript events to identify each visitor with device information and logs all its subsequent events in a page directly accessible through the panel.
Use one of the alternatives below.
If you are using the Kirby CLI you can install this plugin by running the following commands in your shell:
$ cd path/to/kirby
$ kirby plugin:install louis-ev/kirby-tracking
- Clone or download this repository.
- Unzip the archive if needed and rename the folder to
plugin-name
.
Make sure that the plugin folder structure looks like this:
site/plugins/kirby-tracking/
If you know your way around Git, you can download this plugin as a submodule:
$ cd path/to/kirby
$ git submodule add https://github.com/louis-ev/kirby-tracking site/plugins/kirby-tracking
Add the following code to your footer.php
snippet (or copy its content to your js file):
echo js('assets/plugins/kirby-tracking/js/kirby-tracking.js');
Each visit generates a page named with the server's time for the visit, so set the timezone of your site in your config.php
:
c::set('timezone','Europe/Paris');
On first logging event captured, kirby-tracking will check for an existing kirby-tracking
page. If you already have one and it wasn't created by this plugin, please remove it first or you will get blueprints mismatch and errors.
All logs happen in javascript and can be done both with and without a type. For example, to log a simple page load:
logClientEvents('Page loaded.');
For each logged package, the following meta informations will be collected and sent:
- browser — name of browser and version
- device — client's user agent
- event_page — type from which the event originated (with site url automatically replaced with ~)
- event_type — js string sent to logClientEvents (with site url automatically replaced with ~)
- lang — lang of browser
- window_size : browser innerWidth and innerHeight
You can disable tracking for logged-in users in the tracking
page in the panel. If tracking for logged-in users isn’t disabled, they will be identified with the name admin
.
You can disable tracking for bots in the tracking
page in the panel. Bots tracking is made using the browser's user agent and matching it with the following RegExp: "/Googlebot|MJ12bot|yandexbot|Google Page Speed Insights|crawler|spider|robot|crawling|baidu|bing|msn|duckduckgo|teoma|slurp|yandex|Coda,/i".
1.3.0
-
Logs are now regrouped in month pages, for instance:
Kirby Tracking > April 2017 > 2017-04-11 • 16:08:42 — visitor on Firefox 46
-
Escaped data from users as a safety precaution
1.2.0
-
Better bot detection
-
Added option to not log bots
-
Fixed some translations
-
Improved help texts
1.0.0
- Initial release
- If a visitor logs in at some point in her/his navigation, move his status to admin or remove his page if option is set
- Kirby 2.3.0+
This plugin is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please create a new issue.
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.
Thanks to Fabian Sperrle for the kirby-stats plugin that served as inspiration. Thanks to Jens Törnell for the helpful Kirby Boiler Plugin repository.