PHPackages                             poldixd/laravel-matomo-ai-bot-tracking - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. poldixd/laravel-matomo-ai-bot-tracking

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

poldixd/laravel-matomo-ai-bot-tracking
======================================

Track AI bot requests from Laravel in Matomo.

0.2.1(1mo ago)0172MITPHP ^8.2

Since Apr 22Compare

[ Source](https://github.com/poldixd/laravel-matomo-ai-bot-tracking)[ Packagist](https://packagist.org/packages/poldixd/laravel-matomo-ai-bot-tracking)[ Docs](https://github.com/poldixd/laravel-matomo-ai-bot-tracking)[ RSS](/packages/poldixd-laravel-matomo-ai-bot-tracking/feed)WikiDiscussions Synced 3w ago

READMEChangelog (3)Dependencies (10)Versions (10)Used By (0)

Laravel Matomo AI Bot Tracking
==============================

[](#laravel-matomo-ai-bot-tracking)

Track AI bot requests from a Laravel app in Matomo.

This package adds a middleware for Laravel. It uses a fast user-agent string check to detect AI bots and sends these requests to Matomo with `recMode=1`.

What It Does
------------

[](#what-it-does)

The middleware tracks AI bot page requests on the server. It only tracks a request when all of these things are true:

- The request is a `GET` request.
- The request has a `User-Agent` header.
- The user agent contains a known AI bot identifier.
- The request is not asking for JSON.
- The path is not for Livewire, Debugbar, or Telescope.

The request to Matomo contains these fields:

- `idsite`
- `rec=1`
- `recMode=1`
- `url`
- `http_status`
- `bw_bytes`
- `pf_srv`
- `ua`
- `source`

The middleware does not send `cip` or `cdt`. This means it does not override the visitor IP or request time in Matomo.

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

[](#requirements)

- PHP 8.2 or newer
- Laravel 11, 12, or 13
- Matomo with bot tracking support

Matomo bot tracking needs support for the `recMode` tracking parameter.

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

[](#installation)

Install the package with Composer:

```
composer require poldixd/laravel-matomo-ai-bot-tracking
```

Laravel will auto-discover the service provider.

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

[](#configuration)

The package reads its settings from Laravel's `services` config. Add this to `config/services.php`:

```
'matomo' => [
    'enabled' => env('MATOMO_AI_BOT_TRACKING_ENABLED', false),
    'tracking_url' => env('MATOMO_TRACKING_URL'),
    'site_id' => env('MATOMO_SITE_ID'),
    'source' => env('MATOMO_AI_BOT_TRACKING_SOURCE', 'laravel'),
],
```

Then add the values to your `.env` file:

```
MATOMO_AI_BOT_TRACKING_ENABLED=true
MATOMO_TRACKING_URL=https://matomo.example.com
MATOMO_SITE_ID=1
MATOMO_AI_BOT_TRACKING_SOURCE=laravel
```

`MATOMO_TRACKING_URL` is the base URL of your Matomo installation. Do not add `/matomo.php` here. The middleware adds it for you.

Middleware Usage
----------------

[](#middleware-usage)

Register the middleware on the routes where you want to track AI bots.

For a Laravel 11+ application, add it to the middleware configuration in `bootstrap/app.php`:

```
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Middleware;
use poldixd\MatomoAIBotTracking\Middleware\MatomoAIBotTracking;

return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->web(append: [
            MatomoAIBotTracking::class,
        ]);
    })
    ->create();
```

For older Laravel applications that still use `app/Http/Kernel.php`, add it to the `web` middleware group:

```
protected $middlewareGroups = [
    'web' => [
        // ...
        \poldixd\MatomoAIBotTracking\Middleware\MatomoAIBotTracking::class,
    ],
];
```

Behavior
--------

[](#behavior)

When an AI bot request matches the rules above, the middleware waits until Laravel has created the response. Then it sends a form POST request to:

```
{MATOMO_TRACKING_URL}/matomo.php

```

If Matomo tracking fails, the user response is still returned as normal. The error is reported through Laravel and logged with useful request details.

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

Run the code style check with:

```
vendor/bin/pint --test
```

License
-------

[](#license)

MIT

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance89

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Total

3

Last Release

54d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/06ee838e882815b78c994ebb11877afddc8955ec84886af6174e64e4f002d67b?d=identicon)[poldixd](/maintainers/poldixd)

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/poldixd-laravel-matomo-ai-bot-tracking/health.svg)

```
[![Health](https://phpackages.com/badges/poldixd-laravel-matomo-ai-bot-tracking/health.svg)](https://phpackages.com/packages/poldixd-laravel-matomo-ai-bot-tracking)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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