fyrndly/laravel-matomo-tracker
Composer 安装命令:
composer require fyrndly/laravel-matomo-tracker
包简介
A seamless Matomo Analytics integration for Laravel app tracking.
README 文档
README
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.
Features
- Auto-configuration: Automatically detects Client IP, User-Agent, and Browser Language.
- Queue Support: Dispatch tracking requests to the background for high-performance applications.
- User Tracking: Automatically links Matomo User ID with Laravel Auth (configurable attribute).
- Smart Event Tracking: Supports strings, arrays, or objects as payloads (automatically encoded).
- Flexible Tracking: Supports Page Views, Custom Events, Site Search, and Goals.
- Custom Dimensions: Easily set custom dimensions for your tracking data.
- Laravel Integration: Includes a Facade and Service Provider with auto-discovery.
Installation
You can install the package via composer:
composer require fyrndly/laravel-matomo-tracker
The package will automatically register its service provider and facade.
Configuration
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
Configuration Options
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 totrueto handle tracking in the background. Requires a working Laravel Queue worker.
Usage
Using the Facade
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);
Enhanced Event Tracking
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);
Livewire & Filament Auto-Tracking
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).
High Traffic Handling (Queue)
For high-traffic applications, it is highly recommended to enable the queue to prevent API latency from affecting the user experience.
- Set
MATOMO_QUEUE=truein your.env. - Ensure your
QUEUE_CONNECTIONis not set tosync. - Run your queue worker:
php artisan queue:work.
Custom Dimensions
You can set custom dimensions before tracking:
Matomo::setCustomDimension(1, 'Premium User') ->pageView('Dashboard');
Manual User ID
If you need to manually set or override the User ID for a specific request:
Matomo::setUserId('custom-user-id')->pageView('Profile Page');
Accessing the Raw Tracker
If you need to access methods directly from the underlying MatomoTracker instance:
$rawTracker = Matomo::getRawTracker();
Credits
License
The MIT License (MIT). Please see License File for more information.
fyrndly/laravel-matomo-tracker 适用场景与选型建议
fyrndly/laravel-matomo-tracker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 135 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「analytics」 「laravel」 「tracking」 「matomo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fyrndly/laravel-matomo-tracker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fyrndly/laravel-matomo-tracker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fyrndly/laravel-matomo-tracker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP SDK for the Parcel Monkey UK API
Analytics chooser extensions for site settings.
A Laravel Nova Card to show Fathom Analytics stats.
Audit changes of your Eloquent models in Laravel/Lumen
Alfabank REST API integration
Contao 4 Hintergrund-Tracking mit Matomo
统计信息
- 总下载量: 135
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-30