Skip to content

About

A Plone Addon to track AI Chatbot requests in Matomo.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

45 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

collective.matomoaitracker

A addon for Plone which allow you to track requests from AI Chatbots to the server in Matomo.

Features

Tracks the requests of AI bots in Matomo, also when Varnish serves them from its cache, without slowing them down:

  • Varnish classifies AI bots by User-Agent as user (an AI assistant fetching a page for a user, like Claude-User or ChatGPT-User), search (AI search crawlers) or training (training data crawlers), and AI agents browsing with a real browser as agent, and writes that to its log.
  • varnishncsa writes these requests to a log file, and a small shipper sends them in batches to Plone. When Plone or Matomo is down, tracking is delayed, not lost.
  • Plone forwards them to Matomo's bulk tracking API, with the original time of the request. Requests for the resources of pages, like images, styles and scripts, are skipped, and documents like PDFs are tracked as downloads:
    • user requests go to Matomo's AI Chatbots report.
    • Optionally all AI bot requests go to a separate Matomo site as visits, with the bot category, bot name and the Varnish cache status (hit, miss, pass) as custom dimensions. AI agents browsing with a real browser, like ChatGPT's agent, are tracked there as agent, by their Web Bot Auth headers, for Matomo's AI agent reports. Matomo 6 blocks crawler visits from cloud networks by default, see Matomo's tracking spam prevention.

Works with Matomo 5.8 or later, tested with Matomo 5.14 and 6.0.

The control panel "Matomo AI Chatbot Tracking" has the Matomo settings. See the add-on's README for setting up Varnish, varnishncsa and the shipper.

Installation

Install collective.matomoaitracker with pip:

pip install collective.matomoaitracker

And to create the Plone site:

make create-site

The add-on also needs Varnish with its VCL, varnishncsa and the shipper. Each release publishes the images ghcr.io/collective/matomoaitracker-varnishncsa and ghcr.io/collective/matomoaitracker-shipper, see the add-on's README.

Contribute

Prerequisites ✅

Development Installation 🔧

  1. Clone this repository, then change your working directory.

    git clone git@github.com:collective/collective.matomoaitracker.git
    cd collective.matomoaitracker
  2. Install this code base. This also builds the Docker images for the full stack.

    make install

Docker stack 🐳

The full stack runs in Docker:

requests:  Varnish (8001) -> Nginx VirtualHostMonster (8002) -> Plone site "Plone" (8003)
tracking:  Varnish log -> varnishncsa -> ai-bots.log -> shipper -> Plone -> Matomo (8004)

Varnish's configuration (varnish/default.vcl) is based on the one of Plone's cookieplone project templates, tuned for plone.app.caching: Plone purges changed content from Varnish, logged-in users are not cached. For the tracking, Varnish only classifies AI bots and writes the result to its log, it makes no HTTP calls. varnishncsa writes the AI bot requests to a log file, which the shipper sends in batches to Plone, and Plone forwards them to Matomo. By default that is a fake Matomo, which records what it receives for the tests.

make stack-start

On start the Plone site is created, the Matomo settings are applied and the service user for the shipper is created. Settings can be overridden with environment variables or in a .env file, see .env.example:

cp .env.example .env

Note: if you change anything to the create_site.py script, you must remove the matomoaitracker-plone image, otherwise this has no effect.

Simulate an AI chatbot visit, and see what reached the fake Matomo a few seconds later:

curl -A "Claude-User/1.0" http://localhost:8001/
curl http://localhost:8004/_requests

Test the VCL and the varnishncsa format with varnishtest:

make varnish-test

Test the whole tracking chain against the running stack with the fake Matomo: every AI bot is tracked once in the right category, also from the cache, other requests are not, bots are not slowed down, and outages of Matomo or the shipper delay tracking without losing it. These are the pytest tests in tests/stack, which make test skips because they need the stack:

make stack-test

The tests run with Plone's caching policy, and again with pages cached in Varnish for 60 seconds (moderateCaching), restoring the policy afterwards. They log in to Plone's REST API as admin:admin for that, set PLONE_ADMIN=user:password for other credentials.

With a real Matomo

The fake Matomo shows what Plone sends, a real Matomo shows what it stores. With MATOMO_VERSION the stack runs the official Matomo image of that version with MariaDB instead of the fake Matomo (docker-compose.matomo.yml):

make stack-start stack-test MATOMO_VERSION=6.0

make stack-start then installs Matomo with its web installer, creates the AI bots site with its custom dimensions and a Matomo user plone with Write access, and saves that user's token in Plone (scripts/setup_matomo.py). Like a new installation, Matomo 6 blocks visits from cloud networks: the setup loads the cloud IP ranges as Matomo's daily task does. Log in to Matomo on http://localhost:8004 as admin with the password matomo-admin.

The tests check the AI Chatbots requests in Matomo's database and the visits of the AI bots site through its Live API. tests/stack/test_matomo.py also shows how Matomo's settings and tokens affect the tracking: visits from cloud networks, and tokens without Write access.

Pass the same MATOMO_VERSION to every make stack-* target. The official image does not update the Matomo files in its volume: before using another version, remove the data with make stack-remove-data, with the MATOMO_VERSION the stack runs.

Other targets: make stack-logs, make stack-stop and make stack-remove-data.

Release 📦

make release. A release that changes varnish/matomoaitracker.vcl also needs a release of plone-varnish, which ships that file: make update-matomoaitracker VERSION=<release> there.

Add features using plonecli or bobtemplates.plone

This package provides markers as strings (<!-- extra stuff goes here -->) that are compatible with plonecli and bobtemplates.plone. These markers act as hooks to add all kinds of subtemplates, including behaviors, control panels, upgrade steps, or other subtemplates from plonecli.

To run plonecli with configuration to target this package, run the following command.

make add <template_name>

For example, you can add a content type to your package with the following command.

make add content_type

You can add a behavior with the following command.

make add behavior
You can check the list of available subtemplates in the [`bobtemplates.plone` `README.md` file](https://github.com/plone/bobtemplates.plone/?tab=readme-ov-file#provided-subtemplates).
See also the documentation of [Mockup and Patternslib](https://6.docs.plone.org/classic-ui/mockup.html) for how to build the UI toolkit for Classic UI.

License

The project is licensed under MIT, see LICENSE.md.

Credits and acknowledgements 🙏

Generated using Cookieplone (2.0.0) and cookieplone-templates (fa8eca4) on 2026-09-30 17:16:12.816436. A special thanks to all contributors and supporters!

About

A Plone Addon to track AI Chatbot requests in Matomo.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages