PHPackages                             agencetwogether/matomo-analytics - 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. [Admin Panels](/categories/admin)
4. /
5. agencetwogether/matomo-analytics

ActiveLibrary[Admin Panels](/categories/admin)

agencetwogether/matomo-analytics
================================

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

1.1.0(2mo ago)027MITPHPPHP ^8.2CI passing

Since Mar 1Pushed 2mo agoCompare

[ Source](https://github.com/agencetwogether/matomo-analytics)[ Packagist](https://packagist.org/packages/agencetwogether/matomo-analytics)[ Docs](https://github.com/agencetwogether/matomo-analytics)[ GitHub Sponsors](https://github.com/agencetwogether)[ RSS](/packages/agencetwogether-matomo-analytics/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (23)Versions (6)Used By (0)

[![matomo-analytics-art](https://private-user-images.githubusercontent.com/53862310/560815594-410c1b69-6441-4d9f-8c78-049c10cc2a9b.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU0MTk2NzIsIm5iZiI6MTc3NTQxOTM3MiwicGF0aCI6Ii81Mzg2MjMxMC81NjA4MTU1OTQtNDEwYzFiNjktNjQ0MS00ZDlmLThjNzgtMDQ5YzEwY2MyYTliLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA1VDIwMDI1MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMwNzgzNTY3NTUwYmU2ZmE3NTZjNDYzODQ3NTNhMzAxYjQ1NjM5OTgzNWVjY2RlMzQ4NDE0N2NiODA3MWMyMmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.sy7Svn818uCaJd9z_wVsXdubjgBR1nCIe2JKyjKUCk8)](https://github.com/agencetwogether/matomo-analytics) [ ![FILAMENT 4.x](https://camo.githubusercontent.com/13befbe0cffd101b2484ce1cdd985dabcddcbf1176d17a675674d53af99cfdbc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46494c414d454e542d342e782d4542423330343f7374796c653d666f722d7468652d6261646765) ](https://filamentphp.com/docs/4.x/introduction/installation) [ ![FILAMENT 5.x](https://camo.githubusercontent.com/3ec960aa304b803da9f1192f01e82da976a3d220ea85931fec930003e0532c77/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f46494c414d454e542d352e782d4542423330343f7374796c653d666f722d7468652d6261646765) ](https://filamentphp.com/docs/5.x/introduction/installation) [ ![Packagist](https://camo.githubusercontent.com/f5f5526224758298400265ac64725813c5187bd2e5e0b1f4dfa0be21f15271dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6167656e636574776f6765746865722f6d61746f6d6f2d616e616c79746963732e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d7061636b6167697374) ](https://packagist.org/packages/agencetwogether/matomo-analytics) [ ![Code Style Passing](https://camo.githubusercontent.com/2156b30911caa8f487db4323ddce0f2348cf342f2b5f266e5bd7e1e2892fa436/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6167656e636574776f6765746865722f6d61746f6d6f2d616e616c79746963732f6c61726176656c2d70696e742e796d6c3f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6162656c3d636f64652532307374796c65) ](https://github.com/agencetwogether/matomo-analytics/actions?query=workflow%3A) [ ![Downloads](https://camo.githubusercontent.com/4871e0895a7a24f31d086bf9c05503a0b3179e08bd7e07b7cb42dfae03080518/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6167656e636574776f6765746865722f6d61746f6d6f2d616e616c79746963732e7376673f7374796c653d666f722d7468652d6261646765) ](https://packagist.org/packages/agencetwogether/matomo-analytics) [ ![Matomo website](https://camo.githubusercontent.com/3f647b9cd73b655a12dcd4626dc7f98ce99cbbff36c885a518d98327d3db9284/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d61746f6d6f2d416e616c79746963732d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d6d61746f6d6f) ](https://matomo.org)

Matomo Analytics for Filament
=============================

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

[](#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](https://matomo.org/). This plugin is not affiliated with or endorsed by Matomo.

Note

This package is an adaptation of [bezhanSalleh/filament-google-analytics](https://github.com/bezhanSalleh/filament-google-analytics), updated to work with Matomo Analytics for Filament. Thanks to him

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

[](#installation)

You can install the package in a Laravel app that uses [Filament](https://filamentphp.com) 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 the[Filament Docs (V4)](https://filamentphp.com/docs/4.x/styling/overview#creating-a-custom-theme), [Filament Docs (V5)](https://filamentphp.com/docs/5.x/styling/overview#creating-a-custom-theme) 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)

[](#first-you-need-to-retrieve-credentials-from-your-matomo-instance-self-hosted-or-cloud)

#### Matomo API Key

[](#matomo-api-key)

To generate a new API Key go to **Administration-&gt;Personal-&gt;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

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

[](#matomo-id-site)

To retrieve ID of your website you want to track, go to **Administration-&gt;Websites-&gt;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

[](#registering-the-plugin)

```
use Agencetwogether\MatomoAnalytics\MatomoAnalyticsPlugin;

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

Available Widgets
-----------------

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

[](#usage)

You can display the widgets in several ways:

1. [In the default Filament Dashboard](#default_dashboard)
2. [In the Dashboard provided by the plugin](#plugin_dashboard)
3. [In a custom Dashboard](#custom_dashboard)
4. [In any page or resource](#any_page)

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.

```
