alfrasc/laravel-matomo-tracker
Server-side Matomo analytics for Laravel. Track page views, events, goals, and e-commerce without client-side JavaScript, with a fluent API, configurable sites, and user attribution.
Architecture fit. The package is a thin Laravel service-provider wrapper around matomo/piwik-php-tracker, exposing config (Matomo URL, site ID, optional token) and a facade for firing server-side tracking hits (pageviews, events, goals) from controllers, jobs, or console commands. That is the right shape for Laravel: container-bound singleton, publishable config, env-driven credentials. Its real value is closing the gap between browser-only Matomo tracking and backend-only business events (signups, payments, provisioning, webhook-driven state changes) that never touch a pageview.
Integration feasibility. Low-friction on paper: composer require, publish config, set MATOMO_URL/MATOMO_SITE_ID, inject the tracker. The implementation surface is small, so a spike can be done in under a day against a non-production Matomo instance. The friction is entirely in the boundary conditions, not the happy path.
Technical risk. This is the dominant concern:
--ignore-platform-reqs, a fork, or an inline vendoring of the ~few-hundred-line wrapper.NOASSERTION means no recognized SPDX license was detected. Legal cannot approve this for a commercial codebase without clarification from the author or a clean-room reimplementation. For a package this small, reimplementation is often cheaper than the legal review.matomo/piwik-php-tracker, not this wrapper. That library is maintained, but the pinned constraint here will drift from current releases.Key questions.
Stack fit. Best fit is Laravel 8/9 on PHP 7.4–8.1 with a self-hosted Matomo 4.x. On Laravel 10/11 + PHP 8.2+, assume you are forking or wrapping, not consuming as-is. Treat the package as a reference implementation of the Matomo tracking API rather than a dependency you inherit.
Migration path. Do not let the facade leak into application code. Define a narrow internal contract (e.g. AnalyticsTracker::event(string $category, string $action, ?string $label, ?float $value)) with a Matomo-backed implementation. That gives three exits with near-zero refactor cost: keep the package, swap to matomo/piwik-php-tracker directly, or swap to a raw HTTP call against Matomo's Tracking API. Also define an event taxonomy up front — retrofitting consistent category/action naming after launch is far more expensive than the integration itself.
Compatibility. Pin the package exactly, then explicitly constrain and test the transitive tracker version. Verify against the target PHP minor, not just the major. Check for facade alias collisions and confirm the config publish does not overwrite existing config/matomo-tracker.php in multi-tenant or modular setups. If on Laravel 10+, budget for a fork with updated illuminate/support constraints — a one-line change, but one that must be owned and re-applied on every upstream tick.
Sequencing.
Maintenance. Effectively zero upstream velocity. Plan on owning a fork: pin it, mirror it internally, and accept that dependency bumps are yours to make. The code volume is small enough that this is a half-day per year, but it must be explicitly assigned — unowned forks rot silently and break on the next PHP upgrade.
Support. No vendor, no SLA. Community support consists of a 20-star repo and a sole maintainer's goodwill. Internal runbooks and a named owner are mandatory; do not let this become tribal knowledge held by whoever did the initial spike.
Scaling. The default synchronous call is the scaling bottleneck, not Matomo's ingestion. At meaningful event volume you will need queue workers with concurrency limits, batching via Matomo's bulk tracking endpoint, and backpressure so a Matomo outage does not produce an unbounded job backlog. Size the queue and the Matomo instance together; server-side tracking can easily multiply request volume beyond what a lightly-provisioned Matomo expects.
Failure modes.
token_auth exposure → privileged API access leakage. Keep it out of the tracking path entirely; tracking hits do not need it.Ramp-up. A Laravel developer can integrate the happy path in a few hours; the facade and config are self-explanatory. The real ramp-up cost is elsewhere: Matomo's data model (sites, visits, visit scope vs. page scope, goals), event taxonomy design, and consent semantics. Budget days, not hours, for a team new to Matomo — and note that the wrapper hides none of Matomo's conceptual complexity. Given the license ambiguity and 2021 vintage, the pragmatic recommendation is to reimplement the thin wrapper internally against matomo/piwik-php-tracker (or the raw Tracking API): roughly identical effort, no license risk, no bus factor, and full control over queueing, timeouts, and consent.
How can I help you explore Laravel packages today?