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 →
PhpStorm 2026.3 Adds an Agent Workspace and PHP 8.6 Support image

PhpStorm 2026.3 Adds an Agent Workspace and PHP 8.6 Support

Read article
Insert Middleware Before or After Existing Laravel Middleware image

Insert Middleware Before or After Existing Laravel Middleware

Read article
Laravel Herd 2: Coding Agents, Workspaces, and Cloud Deploys image

Laravel Herd 2: Coding Agents, Workspaces, and Cloud Deploys

Read article
Strict Request Input Casting in Laravel image

Strict Request Input Casting in Laravel

Read article
Prevent Duplicate File Uploads With Laravel Storage Dedupler image

Prevent Duplicate File Uploads With Laravel Storage Dedupler

Read article
Slow Job Alerts and Replica Commit IDs in Laravel 13.40 image

Slow Job Alerts and Replica Commit IDs in Laravel 13.40

Read article