PHPackages                             kerkness/fa-wired - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kerkness/fa-wired

ActiveLibrary

kerkness/fa-wired
=================

Fathom Analytic Events for Laravel/Livewire

v1.0.9(11mo ago)163911MITJavaScriptPHP ^8.2CI failing

Since May 28Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/kerkness/fa-wired)[ Packagist](https://packagist.org/packages/kerkness/fa-wired)[ RSS](/packages/kerkness-fa-wired/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

Fathom Analytics Events for Laravel/Livewire
============================================

[](#fathom-analytics-events-for-laravellivewire)

[![Latest Version](https://camo.githubusercontent.com/27b418cf7fcfb82e9ea16dec31e6b17f0720bdcf2fd294e986e20e58f0e871df/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b65726b6e6573732f66612d77697265642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kerkness/fa-wired)[![License](https://camo.githubusercontent.com/f2195010f9dbded0da368aae0522d32631bb78e7f6efcca1dca6648407039cfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b65726b6e6573732f66612d77697265642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kerkness/fa-wired)

A Laravel package that provides Alpine.js directives and magic helpers for seamless Fathom Analytics event tracking in Blade templates and Livewire components.

Features
--------

[](#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

Requirements
------------

[](#requirements)

- **Laravel 10+**
- **PHP 8.2+**
- **Alpine.js 3.x**
- **Livewire 3.x**
- **Fathom Analytics account** with script included in your site

Installation
------------

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require kerkness/fa-wired
```

### 2. Include the JavaScript

[](#2-include-the-javascript)

#### Option A: Import in your build process (Recommended)

[](#option-a-import-in-your-build-process-recommended)

If you're using Vite, or another build tool:

```
// In your app.js or main JavaScript file
import 'vendor/kerkness/fa-wired/dist/fa-wired.esm.js';

// Or with explicit import
import FaWired from 'vendor/kerkness/fa-wired/dist/fa-wired.esm.js';
```

#### Option B: Include directly in Blade template

[](#option-b-include-directly-in-blade-template)

```

```

#### Option C: Via CDN (Alternative)

[](#option-c-via-cdn-alternative)

```

```

### 3. Publish Assets (Optional)

[](#3-publish-assets-optional)

If you want to customize or host the JavaScript yourself:

```
php artisan vendor:publish --provider="Kerkness\FaWired\FaWiredServiceProvider" --tag="fa-wired-assets"
```

This will copy the compiled JavaScript files to `public/vendor/fa-wired/`.

Quick Start
-----------

[](#quick-start)

### Track Button Clicks

[](#track-button-clicks)

```
Get Started
```

### Track Form Submissions

[](#track-form-submissions)

```

    Subscribe

```

### Track from Livewire Components

[](#track-from-livewire-components)

```
// In your Livewire component
public function submit()
{
    // Process form...

    $this->dispatch('fathom-track', name: 'contact form submitted');
}
```

Usage Guide
-----------

[](#usage-guide)

### Alpine.js Directives

[](#alpinejs-directives)

#### Simple Click Tracking

[](#simple-click-tracking)

```

    Track Simple Click

```

#### Click Tracking with Value

[](#click-tracking-with-value)

```

    Track Click with Value ($25.00)

```

#### Form Submission Tracking

[](#form-submission-tracking)

```

    Subscribe

```

#### Download Tracking

[](#download-tracking)

```

    Download User Guide

    Download Pricing

```

#### External Link Tracking

[](#external-link-tracking)

```

    Visit Partner Site

```

### Magic Helper ($fathom)

[](#magic-helper-fathom)

#### Simple Event Tracking

[](#simple-event-tracking)

```

    Simple Track

```

#### Conversion Tracking

[](#conversion-tracking)

```

        Track Conversion ($49.99)

```

#### Advanced Usage

[](#advanced-usage)

```

        Complex Tracking

```

### Livewire Integration

[](#livewire-integration)

#### In your Livewire Component (PHP)

[](#in-your-livewire-component-php)

```
