定制 agencetwogether/matomo-analytics 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

agencetwogether/matomo-analytics

Composer 安装命令:

composer require agencetwogether/matomo-analytics

包简介

Matomo Analytics integration for Filament Panels with a set of widgets to display your analytics data in a beautiful way.

README 文档

README

matomo-analytics-art

FILAMENT 4.x FILAMENT 5.x Packagist Code Style Passing Downloads Matomo website

Matomo Analytics for Filament

Matomo Analytics for Filament integration for Filament Panels with a set of widgets to display your analytics data in a beautiful way.

Features

  • Matomo statistics in Filament dashboard
  • Page views
  • Unique visitors
  • Visit duration
  • Country statistics
  • City statistics
  • Period filters...

Note

Matomo is a trademark of the Matomo project. This plugin is not affiliated with or endorsed by Matomo.

Note

This package is an adaptation of bezhanSalleh/filament-google-analytics, updated to work with Matomo Analytics for Filament. Thanks to him

Installation

You can install the package in a Laravel app that uses Filament via composer:

composer require agencetwogether/matomo-analytics

Important

If you have not set up a custom theme and are using Filament Panels follow the instructions in theFilament Docs (V4), Filament Docs (V5) first.

After setting up a custom theme add the following to your theme css file.

@source '../../../../vendor/agencetwogether/matomo-analytics/resources/views/**/*';
@source '../../../../vendor/agencetwogether/matomo-analytics/src/{Widgets,Support}/*';

Then rebuild your assets:

npm run build

First you need to retrieve credentials from your Matomo instance (self-hosted or cloud)

Matomo API Key

To generate a new API Key go to Administration->Personal->Security and click on Create new token button.

  • Give a description as you want,
  • Uncheck Only allow secure requests
  • And set or no an exire date.

Matomo Base Url

Copy Url of your instance with http or https prefix and remove slash (/) at the end. For example, your base Url must be like : https://analyse.domain.com

Matomo ID Site

To retrieve ID of your website you want to track, go to Administration->Websites->Manage and copy the ID below site name.

After that, add these credentials to the .env for your Filament PHP app:

MATOMO_API_KEY=
MATOMO_BASE_URL=
MATOMO_ID_SITE=

For example, it might look like this

MATOMO_API_KEY="d26fa64666d15073d9a8e49101422c06"
MATOMO_BASE_URL="https://analyse.domain.com"
MATOMO_ID_SITE=1

Registering the plugin

use Agencetwogether\MatomoAnalytics\MatomoAnalyticsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            //...
            MatomoAnalyticsPlugin::make()
        ]);
}

Available Widgets

use Agencetwogether\MatomoAnalytics\Widgets;

Widgets\PageViewsWidget::class, // Displays the total number of page views
Widgets\VisitorsWidget::class, // Displays the number of unique visitors
Widgets\VisitsWidget::class, // Displays the total number of visits
Widgets\VisitsDurationWidget::class, // Shows the average duration of visits
Widgets\VisitorsFrequenciesWidget::class, // Shows visitor frequency (returning visitors)
Widgets\VisitorsFrequenciesDurationWidget::class, // Shows visit duration based on visitor frequency
Widgets\VisitsByCountryWidget::class, // Displays visits grouped by country
Widgets\VisitsByCityWidget::class, // Displays visits grouped by city
Widgets\VisitsPerHourWidget::class, // Shows visits distribution by hour of the day
Widgets\VisitsByBrowserListWidget::class, // Lists visits by browser
Widgets\VisitsByDeviceWidget::class, // Displays visits by device type (desktop, mobile, tablet)
Widgets\VisitsByModelListWidget::class, // Lists visits by device model
Widgets\MostVisitedPagesWidget::class, // Displays the most visited pages
Widgets\TopReferrersListWidget::class, // Lists the top traffic referrers

Usage

You can display the widgets in several ways:

  1. In the default Filament Dashboard
  2. In the Dashboard provided by the plugin
  3. In a custom Dashboard
  4. In any page or resource

To manage these displays, publish the configuration file:

 php artisan vendor:publish --tag=matomo-analytics-config

Then modify the settings depending on your use case.

1. Default Filament Dashboard

For the desired widget, set the value filament_dashboard to true
Example:

'widgets' => [
    'page_views' => [
        'filament_dashboard' => true,
        // ..
    ],
],

2. Dashboard provided by the plugin

Ensure dedicated_dashboard is set to true in config file to show dashboard provided by the plugin.
For the desired widget, set the value plugin_dashboard to true
Example:

'widgets' => [
    'visits_by_browser_list' => [
        // ..
        'plugin_dashboard' => true,
        // ..
    ],

    'most_visited_pages' => [
        // ..
        'plugin_dashboard' => true,
        // ..
    ],
],

3. Custom Dashboard

Though this plugin comes with a default dashboard, but sometimes you might want to change navigationLabel or navigationGroup or personalize some widgets or any other options.
The easiest solution would be to disable the default dashboard and create a new page.

First, create a page using the command:

php artisan make:matomo-page MyCustomDashboardPage

This page extends the base page MatomoBaseAnalyticsDashboard and implement the HasMatomoWidgets interface.

<?php

namespace App\Filament\Pages;

use Agencetwogether\MatomoAnalytics\Contracts\HasMatomoWidgets;
use Agencetwogether\MatomoAnalytics\Pages\MatomoBaseAnalyticsDashboard;
use Agencetwogether\MatomoAnalytics\Widgets;

class MyCustomDashboardPage extends MatomoBaseAnalyticsDashboard implements HasMatomoWidgets
{
    protected static ?string $title = 'My Custom Dashboard';
    
    public function getMatomoWidgets(): array
    {
        return [
            Widgets\PageViewsWidget::class,
            Widgets\VisitorsWidget::class,
            //Add other widgets
        ];
    }
}

You must register the widgets you want to show in the getMatomoWidgets() method and set their custom_pages values to true in the configuration file.
Example:

'widgets' => [
    'page_views' => [
        // ..
        'custom_pages' => true,
    ],
    'visitors' => [
        // ..
        'custom_pages' => true,
    ],
],

4. Other Page or Resource page

You have to register the desired widgets in the page’s getHeaderWidgets() or getFooterWidgets() method.

use Agencetwogether\MatomoAnalytics\Widgets;

protected function getHeaderWidgets(): array
{
    return [
        Widgets\VisitsByCountryWidget::class,
        Widgets\VisitsByCityWidget::class,
    ];
}

And in the configuration file, set the custom_pages value to true for the selected widgets.
Example:

'widgets' => [
    'visits_by_country' => [
        // ..
        'custom_pages' => true,
    ],
    'visits_by_city' => [
        // ..
        'custom_pages' => true,
    ],
],

Manage cache

By default, responses from requests to the Matomo server are cached to avoid sending too many requests and to optimize widget rendering.
You can enable or disable caching widgets and set custom time to cache per filter (in minutes). See config file to manage this feature.

Note

If the Matomo server request fails or is unavailable, a widget will appear indicating that the data may be outdated or empty. However, the cache still allows the data from the last successful synchronization to be displayed (only in default Filament Dashboard, Dashboard provided by the plugin and Custom Dashboard)

Preview

Widgets rendered in a dedicated dashboard (or any other page you create) Light mode Preview Dark mode Preview

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

agencetwogether/matomo-analytics 适用场景与选型建议

agencetwogether/matomo-analytics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 107 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「analytics」 「laravel」 「dashboard」 「matomo」 「filament」 「filament-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 agencetwogether/matomo-analytics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 agencetwogether/matomo-analytics 我们能提供哪些服务?
定制开发 / 二次开发

基于 agencetwogether/matomo-analytics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 107
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 12
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-01