Download the PHP package hamaka/silverstripe-matomo-ai-tracking without Composer

On this page you can find all versions of the php package hamaka/silverstripe-matomo-ai-tracking. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package silverstripe-matomo-ai-tracking

Silverstripe Matomo AI tracking

Tracks requests from AI chatbots (ChatGPT-User, Claude-User, Perplexity-User, …) in Matomo AI Insights using server-side middleware.

AI assistants fetch your pages on behalf of their users, but they don't execute JavaScript, so the regular Matomo tracking code never sees them. This module detects these requests in PHP and sends them to the Matomo HTTP Tracking API in "bot only" mode (recMode=1). They show up under AI Insights without affecting your visitor statistics.

Requirements

Installation

Flush afterwards: ?flush=1 in the browser, or on the command line vendor/bin/sake dev/build flush=1 (Silverstripe 5) or vendor/bin/sake flush (Silverstripe 6). No database build is needed: the module adds no tables.

Configuration

Tracking is off by default. Enable it per environment in .env:

The site URL is taken from the request itself. Behind a proxy or load balancer that terminates TLS, make sure Silverstripe recognises the request as https (SS_TRUSTED_PROXY_IPS), or set MATOMO_AI_TRACKING_SITE_URL.

No token is needed: hits are always sent in real time.

Tip: only enable it on live (or point test environments to a separate Matomo site ID), otherwise test hits end up in your production statistics.

Optional YAML configuration

Excluded paths and downloads are single regexes. Setting one in YAML replaces the default, so copy the default from src/AiBotDetector.php and extend it. For example, to also exclude /api/:

User agents: user_agent_patterns is a list. Silverstripe merges lists from YAML with the default instead of replacing them, so a YAML list can only add patterns. Adding one rarely helps: Matomo only counts the AI chatbots its BotTracking plugin knows and silently drops the rest. To track fewer bots, replace the list in _config.php:

Tracker settings:

How it works

Full-page caches

The middleware only sees requests that reach Silverstripe's Director:

For those setups, bots that get a cached page never reach PHP. Track them at the proxy/CDN level or exclude AI chatbot user agents from the cache.

Limitation: files served directly by the webserver

Existing files in assets/ (PDFs, documents) are served by Apache/nginx without starting PHP, so this middleware never sees them. If you want to know which documents AI assistants read, route only AI chatbot requests for those files through Silverstripe. Regular visitors are unaffected.

Apache: add this before the "Non existant files passed to requesthandler" block in public/assets/.htaccess. That file is generated, so put the rule in your project's override of the template templates/SilverStripe/Assets/Flysystem/PublicAssetAdapter_HTAccess.ss (mind the capitals on case-sensitive file systems), then regenerate it with a flush.

The rule uses [.] instead of \. on purpose: backslashes in that template are escaped (the existing rules use \\. and \\\\), so a pasted \. may not end up in .htaccess as written. Always check the generated public/assets/.htaccess.

nginx: use an equivalent location block with an if ($http_user_agent ~* ...) rewrite to index.php.

Check that Silverstripe then actually serves the file (status 200) on your setup. Keep the list of bots in sync with user_agent_patterns.

Running the tests

The tests/ folder is not part of the Packagist download (see .gitattributes). Install the module from source in a Silverstripe project to run them:

If the tests fail with "getItemPath returned null", the class manifest is stale. Silverstripe picks up a flush argument from the command line. With PHPUnit 9 (Silverstripe 5) use:

PHPUnit 10+ (Silverstripe 6) treats extra arguments as test paths, so this trick doesn't work there; see the Silverstripe 6 testing docs for how to flush before a test run.

License

BSD-3-Clause, see LICENSE.md.


All versions of silverstripe-matomo-ai-tracking with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
silverstripe/framework Version ^5 || ^6
guzzlehttp/guzzle Version ^7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hamaka/silverstripe-matomo-ai-tracking contains the following files

Loading the files please wait ...