Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Matomo Php Tracker Laravel Package

matomo/matomo-php-tracker

Official PHP client for Matomo Analytics that enables server-side tracking of page views, events, goals, ecommerce, and custom dimensions from PHP applications. Supports bulk requests, visitor attribution, and privacy-friendly analytics without relying on client-side JavaScript.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit — This is a framework-agnostic HTTP client for Matomo's Tracking API (matomo.php), not a Laravel package. There is no service provider, config publish, facade, or container binding. Architecturally it belongs at the edge of the application as an outbound telemetry adapter: it should never be called from domain/services directly, but behind a narrow port (AnalyticsTracker::pageView(), ::event(), ::purchase()) that the app owns. That inversion is cheap to build and is the single highest-value decision here, because it lets you swap Matomo for GA4, a null tracker in tests, or a future vendor without touching call sites.

Integration feasibility — Low-to-moderate. Install via Composer and write ~100–200 LOC of glue: a config file (MATOMO_URL, MATOMO_SITE_ID, optional MATOMO_TOKEN), a singleton binding, and an adapter class. Two feasibility checks up front: (1) confirm the pinned version ships PSR-4 autoload metadata rather than requiring a manual require of a single MatomoTracker.php file — historically this library was designed as a drop-in include and Composer support has lagged; (2) confirm the transport is injectable or interceptable, because the built-in cURL-based sender is awkward to mock in Laravel's HTTP fake layer.

Technical risk — The class is stateful and mutable (setUrl, setVisitorId, setUserId, setCustomDimension, setIp, setTokenAuth). Bound as a singleton in a standard FPM request that is fine; under Octane, queue workers, or any long-lived process it leaks visitor state between requests and will silently corrupt attribution. This is the top operational hazard and must be designed for explicitly (per-request resolution or a reset() in middleware/job teardown). Secondary risks: calls are synchronous outbound HTTP on the request path; the library historically swallows transport failures rather than throwing, which is good for UX and bad for data-quality observability; and the ecosystem signal here is thin (219 stars, 0 listed dependents), which means fewer Stack Overflow answers and less Laravel-community battle-testing than, say, a spatie/* package. Note the dependent count is likely understated because Matomo's own plugins vendor the file directly — worth verifying before treating it as a red flag.

Key questions

  • Do we need server-side tracking at all, or does the client-side JS tracker + Matomo Tag Manager already cover the funnel? Server-side is justified mainly for actions the browser cannot see (payment settlement, refunds, backend provisioning, webhook-driven signups) and for ad-blocker resilience.
  • Which Matomo deployment (Cloud vs. self-hosted, version) and does its Tracking API support the parameters we need (custom dimensions, ecommerce, bulk)?
  • What is our consent model, and who is accountable for forwarding setConsentGiven() correctly so we do not create a GDPR/CCPA liability by tracking server-side before consent?
  • Can we intercept outbound HTTP in CI, or is a wrapper interface required to test at all?
  • What is the tolerable data-loss rate if Matomo is down — is fire-and-forget acceptable, or do events need a durable queue?

Integration Approach

Stack fit — PHP 7.4/8.x, Laravel 9–11. Zero framework coupling, so it composes cleanly; the cost is that all Laravel ergonomics (config, DI, facades, testing helpers) are ours to write. BSD-3-Clause is permissive and safe for proprietary use; only a redistribution-attribution obligation.

Migration path — If a Matomo JS tracker is already live, keep it and run the PHP tracker alongside it, not as a replacement. Critically, pass the JS tracker's _id cookie through setVisitorId() and your authenticated user through setUserId() so server-side events stitch into the same visit rather than creating orphaned visitors and double-counted sessions. If migrating from GA/another vendor, dual-run for 2–4 weeks and reconcile event counts before decommissioning.

Compatibility — Validate PHP version constraints in composer.json, and pin an exact version — release cadence is irregular, so "latest" is not a stable contract. Confirm the target Matomo instance's major version and Tracking API parameter support; Matomo's ecommerce and custom-dimension semantics have shifted across majors.

Sequencing

  1. Spike (1–2 days): throwaway script proving POST, site ID, bulk, and a custom dimension against a non-production Matomo site.
  2. Adapter + config (2–3 days): AnalyticsTracker interface, Matomo implementation, null implementation for tests/local.
  3. Async transport (2–3 days): queue job, batch via doBulkTrack, retry/backoff, dead-letter handling.
  4. Consent + identity (2 days): middleware for consent state, visitor/user ID propagation, IP anonymization policy.
  5. Observability (1–2 days): emit a counter on send failure; a silent tracker is an untrustworthy one.
  6. Cutover + reconciliation (1 sprint): dual-run, compare against JS tracker, then retire.

Operational Impact

Maintenance — Low surface area (an HTTP client, no native extensions, no database), but the dependency is effectively maintained by the Matomo org with a small external contributor base. Budget for reading the changelog on every bump rather than assuming semver safety, and expect to own your own glue layer indefinitely — it will not be maintained upstream for you.

Support — No vendor SLA outside a Matomo Cloud subscription; support is GitHub issues plus the Matomo forums. Internal knowledge will sit with whoever writes the adapter, so document it. The real support burden is usually not the library but the Matomo instance itself — archiving crons, database growth, segment performance — which is an ops ownership question to settle before adoption.

Scaling — Bulk tracking plus a queue is the right shape; a synchronous doTrack* call per event will add latency to user requests and collapse under load. Watch Matomo-side ingest: a fleet of queue workers replaying a backlog can flood the Tracking API and starve archiving. Cap worker concurrency and align with Matomo's archiving window.

Failure modes — (1) State bleed under Octane/queue workers → wrong visitor attribution, near-impossible to debug after the fact. (2) Silent drops when Matomo times out or the site ID is wrong → dashboards look fine, revenue attribution quietly degrades. (3) Consent violations from tracking before setConsentGiven() is set. (4) Duplicate visitors when server-side and client-side IDs are not stitched. (5) Unbounded queue growth if Matomo is down and retries are not capped.

Ramp-up — A mid-level Laravel developer is productive in half a day on the library itself; the adapter, queue, consent, and testing design is roughly one sprint of design attention. The non-obvious onboarding cost is domain knowledge: understanding that this tracker is a complement to the JS tracker, and where each is authoritative.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package