A seamless Matomo Analytics integration for Laravel app tracking.
fyrndly/laravel-matomo-tracker is a Laravel package for a seamless matomo analytics integration for laravel app tracking..
It currently has 1 GitHub stars and 139 downloads on Packagist (latest version v1.2.0).
Install it with composer require fyrndly/laravel-matomo-tracker.
Discover more Laravel packages by fyrndly
or browse all Laravel packages to compare alternatives.
Last updated
A seamless and lightweight Matomo Analytics integration for Laravel application tracking. This package wraps the official Matomo PHP Tracker to provide a Laravel-friendly syntax, including Facades, auto-configuration, and background processing.
You can install the package via composer:
composer require fyrndly/laravel-matomo-tracker
The package will automatically register its service provider and facade.
First, publish the configuration file:
php artisan vendor:publish --tag="matomo-config"
Then, add your Matomo details to your .env file:
MATOMO_URL=https://your-matomo-domain.com
MATOMO_SITE_ID=1
MATOMO_TOKEN=your_auth_token_here
MATOMO_USER_ID_ATTRIBUTE=email
# Enable Queue for high-traffic apps
MATOMO_QUEUE=false
url: Your Matomo server URL.site_id: Your Matomo site ID.token: Required for manual IP tracking or administrative features.user_id_attribute: The attribute from the User model to use as the Matomo User ID (e.g., email, id).queue: Set to true to handle tracking in the background. Requires a working Laravel Queue worker.use FyrnDly\Matomo\Facades\Matomo;
// Track a Page View
Matomo::pageView('Home Page');
// Track a Goal
Matomo::goal(1, 50.0);
// Track Site Search
Matomo::search('search keyword', 'category', 10);
The event method supports complex data. If you pass an array or object to the $payload parameter, it will be automatically JSON-encoded and Base64-encoded for safe storage in Matomo.
// Simple Event
Matomo::event('Category', 'Action', 'Simple Name');
// Event with Payload (Array/Object)
$data = [
'user_type' => 'premium',
'source' => 'referral',
'step' => 3
];
Matomo::event('Onboarding', 'StepCompleted', $data);
You can effortlessly track page views in your Livewire components or Filament pages by simply including the MatomoTrackView trait. It hooks into the component's lifecycle and automatically resolves the page title.
use Livewire\Component;
use FyrnDly\Matomo\Traits\MatomoTrackView;
class Dashboard extends Component
{
use MatomoTrackView;
public $pageTitle = 'Main Dashboard'; // Automatically tracked as "Go to page Main Dashboard"
}
Note: This trait smartly looks for $pageTitle, $title, $heading properties, or getTitle(), getHeading(), getRecordTitle() methods (perfect for Filament v3).
For high-traffic applications, it is highly recommended to enable the queue to prevent API latency from affecting the user experience.
MATOMO_QUEUE=true in your .env.QUEUE_CONNECTION is not set to sync.php artisan queue:work.You can set custom dimensions before tracking:
Matomo::setCustomDimension(1, 'Premium User')
->pageView('Dashboard');
If you need to manually set or override the User ID for a specific request:
Matomo::setUserId('custom-user-id')->pageView('Profile Page');
If you need to access methods directly from the underlying MatomoTracker instance:
$rawTracker = Matomo::getRawTracker();
The MIT License (MIT). Please see License File for more information.