The Fathom Analytics package for Laravel Livewire provides Alpine.js directives and helpers for seamless Fathom Analytics event tracking in Blade templates and Livewire components.
After installation and setup, you can use Alpine.js directives or the $fathom
magic helper to track events:
<!-- Simple tracking --><button x-track-click="button click"> Track Simple Click</button> <!-- Click event with a value --><button x-track-click="{ event: 'premium button', value: 2500 }"> Track Click with Value ($25.00)</button> <!-- Form submissions --><form x-track-submit="newsletter signup"> <input type="email" placeholder="Enter email"> <button type="submit">Subscribe</button></form> <!-- Simple event using the $fathom helper --><button @click="$fathom.track('magic helper test')"> Simple Track</button> <!-- Conversion tracking --><div x-data="{ productPrice: 4999 }"> <button @click="$fathom.conversion('product purchase', productPrice)"> Track Conversion ($49.99) </button></div>
You can also dispatch events from a Livewire component to track events:
// Simple tracking$this->dispatch('fathom-track', name: 'contact form submitted'); // With a value$this->dispatch('fathom-track', name: 'high value lead', value: 5000 // $50.00 in cents);
Be sure to check out the usage guide for more examples.
Main Features
- Alpine.js Directives - Simple HTML attributes for tracking clicks, form submissions, downloads, and external links
- Magic Helper - $fathom magic helper for programmatic tracking in JS
- Livewire Integration - dispatch tracking events from Livewire components
- Track E-commerce Values - Track conversions with values in cents
- Simple Click Tracking - Track simple clicks, configurable tracking values, form submissions, downloads, and external link clicks.
Check it out on GitHub: kerkness/fa-wired.