Laravel Packages

Fathom Analytics Events for Laravel Livewire

Published
Fathom Analytics Events for Laravel Livewire image

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.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Laravel AutoBuilder: Build Visual Automation Workflows image

Laravel AutoBuilder: Build Visual Automation Workflows

Read article
Pun: Format, Lint, and Analyze PHP With One Rust Binary image

Pun: Format, Lint, and Analyze PHP With One Rust Binary

Read article
Form Request Model Lookups and PHP 8.6 Support in Laravel 13.44 image

Form Request Model Lookups and PHP 8.6 Support in Laravel 13.44

Read article
Generate Laravel Validation Rules From a JSON Schema image

Generate Laravel Validation Rules From a JSON Schema

Read article
Laravel Suspicious Login: Detect and Block Risky Logins image

Laravel Suspicious Login: Detect and Block Risky Logins

Read article
Decide with Jev: Make Failed AI Requests Safe in Laravel image

Decide with Jev: Make Failed AI Requests Safe in Laravel

Read article