xima / xima-typo3-matomo-deferred-tracking
Sends the server-side Matomo tracking requests of pagemachine/matomo-tracking after the response has been delivered
Package info
github.com/xima-media/xima-typo3-matomo-deferred-tracking
Type:typo3-cms-extension
pkg:composer/xima/xima-typo3-matomo-deferred-tracking
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.0
- pagemachine/matomo-tracking: ^1.2
- psr/http-client: ^1.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- typo3/cms-core: ^12.4 || ^13.4 || ^14.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
TYPO3 extension that sends the server-side Matomo tracking requests of pagemachine/matomo-tracking after the response has been delivered to the visitor.
Why
The tracker sends its request synchronously while the page is being built, using TYPO3's
shared HTTP client. When Matomo is slow (restart, network hiccup, load), every tracked page
view waits up to $GLOBALS['TYPO3_CONF_VARS']['HTTP']['timeout'].
With this extension:
- Under PHP-FPM, the tracker gets an immediate
204and the request is queued. A shutdown function callsfastcgi_finish_request()(the response is delivered and the connection closed) and then sends the queue. Failures are logged asERRORbyXima.XimaTypo3MatomoDeferredTracking.Http.DeferredHttpClient. - Other SAPIs (CLI) send synchronously, as before.
- Tracking requests use their own short timeout. TYPO3's proxy, TLS and header settings still apply.
Works with pagemachine/typo3-matomo-tracking
and with own integrations of pagemachine/matomo-tracking: a compiler pass replaces the
HTTP client of Pagemachine\MatomoTracking\Tracking\ActionTracker, whatever defines it.
Installation
composer require xima/xima-typo3-matomo-deferred-tracking
Nothing else to configure. Remove an own $httpClient argument of the ActionTracker in
your site package; the extension replaces it anyway.
Configuration
Extension settings (Admin Tools > Settings > Extension Configuration):
| Setting | Default | |
|---|---|---|
timeout |
1 |
Total timeout of a tracking request in seconds |
connectTimeout |
0.5 |
Timeout for the connection in seconds |
A hanging Matomo still keeps the PHP-FPM worker busy until the timeout, but only after the response has been delivered.
Upstream
Proposed as an option of the extension itself: pagemachine/typo3-matomo-tracking#44. Once that exists, this extension can be removed.
Development
composer install
composer ci # php-cs-fixer, PHPStan, PHPUnit
License
GPL-2.0-or-later