darvis/livewire-google-analytics
Easily add Google Analytics to your Livewire apps with a simple component. Track page views, events, and user interactions without writing JavaScript, keeping analytics setup clean and configurable in Laravel.
wire:navigate transitions — become declarations in PHP rather than tag-manager configuration. This is the main use case: intent-level analytics on an app where page views under-report what users actually did.gtag.js, has no measurement ID setting, does no consent handling, and sends nothing from the server. Evaluate it against GTM dataLayer pushes (more flexible, decoupled from PHP), hand-rolled $wire/Alpine dispatches (zero dependency, more boilerplate), or a full analytics SDK (heavier, more lock-in).…AfterRedirect() method is written into the next page's listener script as escaped JSON; (2) the package knows nothing about consent — it sends a waiting event once window.gtag exists, and ['queue' => false] turns that off. Whether event params may carry user identifiers or free text is therefore a PM/compliance call made before rollout, not an implementation detail discovered in review.No hint path defined for [livewire-google-analytics] vs View [script] not found) reduce the debugging tax that usually lands on the PM as "why is this not working."Consider it when:
gtag.js loading, the measurement ID, and consent gating. The package is designed to sit on top of an existing GA4 setup, not to install one.…AfterRedirect() variants), event declarations that appear in code review and diffs.wire:navigate, but carried events from the new page are sent.debug_mode on the tag or per-event via 'debug_mode' => true, Tag Assistant, and GA4 DebugView under Admin → Data display.Look elsewhere when:
…AfterRedirect() behaviour is a blocker until you have reviewed the data you send.For executives. A narrowly scoped, low-cost way to get real product analytics out of a Livewire application: it records the behaviours we care about — form steps, submissions, validation failures, navigation — as code-reviewed event declarations. It adds no tracking script, no measurement ID setting, and no vendor lock-in, so it composes with whatever analytics and consent stack we already run rather than replacing it. The trade-off is explicit and now documented on the index page: we own consent and GA configuration ourselves, which means a short legal/analytics-ops sign-off before launch, not an engineering surprise. This release is documentation only — no code change, no breaking change, no migration.
For engineering. v1.3.2 is docs-only; upgrading touches nothing in src/. What changed is that the documentation now matches the code and stops over-claiming. Three corrections matter for anyone already instrumented: (1) …AfterRedirect() events are serialized into the next page's listener script as escaped JSON — the "values are never written into a script" claim was true only before 1.3.0; (2) Google's consent mode does not "do the rest" for queued events — the package just waits for window.gtag and ['queue' => false] disables that; (3) the listener does listen a second time under wire:navigate, but it does send the new page's carried events, and all eight trait methods are protected, not four. The new quickstart (complete contact form) and the install-page verification steps — console checks, a pasteable test event, what DebugView looks like on success and what it means when you see something else — are the fastest path to a first confirmed event in a fresh environment. Treat the "what this package does not do" list as the integration contract: bring your own gtag.js, measurement ID, consent handling, and a separate mechanism if you need anything server-side.
How can I help you explore Laravel packages today?