luketowers/laravel-ga4-event-tracking
Server-side Google Analytics 4 event tracking for Laravel. Send events to GA4's Measurement Protocol from your backend using a simple, fluent API, keeping credentials out of the browser and giving you full control over the payloads you send.
Architecture fit
laravel-ga4-event-tracking is a single-purpose adapter between a Laravel application and the GA4 Measurement Protocol. It sits at the outbound edge of the system: no schema, no migrations, no auth surface, no long-lived state. That makes it an architecturally cheap dependency — it can be adopted for one conversion event without reshaping anything else, and removed just as cleanly. Its natural role is server-side conversion reporting where the browser-side gtag path is unreliable (ad blockers, consent-gated clients, webhooks, back-office and offline events like refunds or subscription changes that never touch a pageview).
Integration feasibility
Low. The expected path is composer require, publish the config, supply a GA4 measurement ID and Measurement Protocol API secret per environment, and dispatch events. Realistic effort for a first event is well under a day for an engineer already fluent in Laravel, with most of that time spent verifying payloads in GA4 DebugView rather than writing code.
Technical risk Low-to-moderate, and mostly concentrated outside the package itself:
Key questions
illuminate/* constraint, or does it also drop support for Laravel 10/11/12? Patch version implies no breaks, but the composer constraint needs to be read directly.Http::fake() in tests and assert payload shape?user_id / client_id stitching and event-level timestamp_micros, or is every event treated as "now, anonymous"?Stack fit
Standard Laravel idiom — service provider, facade or injected client, config file, .env-driven credentials, and the framework HTTP client underneath. It should slot in alongside whatever queue and HTTP conventions we already use, with no new infrastructure. Verify the supported Laravel/PHP matrix against our current runtimes before committing; if we are mid-upgrade to Laravel 13 this release is effectively a prerequisite, and if we are still on an older major, confirm 2.2.1 has not quietly raised the floor.
Migration path
Treat this as greenfield adoption rather than migration. From v2.2.0 this is a patch release with no stated breaking changes, so no upgrade steps are implied. If we are replacing a hand-rolled Measurement Protocol wrapper, the safer path is to run both in parallel for a sprint, tagging events with a distinguishing parameter, and compare GA4 Realtime/DebugView against the incumbent before deleting anything. If we are moving events from client-side gtag to server-side, expect a discontinuity in attribution — plan for a reporting annotation rather than trying to make the two series splice cleanly.
Compatibility
The release note is a single line, so confidence in backward compatibility comes from the semver signal, not from documentation. Pin to ^2.2 in composer.json, let CI exercise the constraint, and read the diff before bumping. There is no changelog detail on what "Update for Laravel 13" entailed — assume composer.json and CI matrix only until proven otherwise.
Sequencing
Maintenance Runtime maintenance is negligible; there is nothing to run. The recurring cost is an annual-ish version alignment when a new Laravel major lands — which is precisely what this release is. Budget a recurring ticket each Laravel upgrade cycle to verify this package has shipped compatible constraints, and be prepared to pin the framework upgrade behind it if it lags.
Support Community open source with a small maintainer base and one new contributor on this release. There is no vendor SLA. Mitigate by keeping our usage narrow and conventional, and by recording internally how to fork and patch in case upstream goes quiet. Given the size of the package, an internal vendored fork is a realistic contingency, not a drastic one.
Scaling Throughput-bound rather than connection-bound. On the request path, each event costs an outbound HTTP round trip to Google, which is the wrong trade for high-volume flows — queue it. At higher volumes, prefer batching multiple events per request and confirm the package exposes that; if not, expect to wrap it. Be aware of Measurement Protocol payload-size and event-volume quotas and validate against them before, not after, a traffic spike.
Failure modes
config:cache after an env change is a classic silent-failure source in Laravel deployments.Ramp-up Low — a competent Laravel engineer can be productive in under a day. The real ramp-up cost is analytics literacy, not code: whoever owns this needs enough GA4 knowledge to define an event taxonomy, name parameters consistently, and read DebugView. Assign that ownership explicitly, otherwise events accumulate ad hoc and the reports become unreconcilable.
Evidence note: this assessment is based solely on the v2.2.1 release notes (a Laravel 13 compatibility update) and general knowledge of the package's role. Before finalizing, pull the diff, the composer.json constraint, and the README to firm up the compatibility matrix, queueing behavior, and batching support flagged above.
How can I help you explore Laravel packages today?