chessio / module-matomo

chessio/module-matomo

Matomo Analytics module for Magento 2

magento2-module Compatibility: Partially compatible Code Quality: Fail Tests: N/A Security: Pass AGPL-3.0+

Matomo Integration for Magento 2

Chessio_Matomo is a Matomo web analytics module for the Magento 2 eCommerce platform. Matomo is an extensible free/libre analytics tool that can be self-hosted, giving you complete data ownership. Chessio_Matomo lets you integrate Matomo with your Magento 2 store front.

This module is the successor of Henhed_Piwik and thus continues with its semantic versioning, beginning with version v2.1.0 . If you're using a Magento version prior to 2.2, you'll need to stick to the 1.x releases of the original Henhed_Piwik. For manual installation, check out the Releases archive. For installation using Composer, you can use the tilde or caret version constraint operators (e.g. ~1.3 or ^1.3.1).

Installation

To install Chessio_Matomo, download and extract the main zip archive and move the extracted folder to app/code/Chessio/Matomo in your Magento 2 installation directory.

unzip magento2-matomo-main.zip
mkdir app/code/Chessio
mv magento2-matomo-main app/code/Chessio/Matomo

Alternatively, you can clone the Chessio_Matomo Git repository into app/code/Chessio_Matomo.

git clone https://github.com/fnogatz/magento2-matomo.git app/code/Chessio/Matomo

Or, if you prefer, install it using Composer.

composer require chessio/module-matomo

Finally, enable the module with the Magento CLI tool.

php bin/magento module:enable Chessio_Matomo --clear-static-content

Configuration

Once installed, configuration options can be found in the Magento 2 administration panel under Stores/Configuration/Sales/Matomo API.
To start tracking, set Enable Tracking to Yes, enter the Hostname of your Matomo installation and click Save Config. If you have multiple websites in the same Matomo installation, make sure the Site ID configured in Magento is correct.

Customization

If you need to send some custom information to your Matomo server, Chessio_Matomo lets you do so using event observers.

To set custom data on each page, use the matomo_track_page_view_before event. A tracker instance will be passed along with the event object to your observer's execute method.

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $tracker = $observer->getEvent()->getTracker();
    /** @var \Chessio\Matomo\Model\Tracker $tracker */
    $tracker->setDocumentTitle('My Custom Title');
}

If you only want to add data under some specific circumstance, find a suitable event and request the tracker singleton in your observer's constructor. Store the tracker in a class member variable for later use in the execute method.

public function __construct(\Chessio\Matomo\Model\Tracker $matomoTracker)
{
    $this->_matomoTracker = $matomoTracker;
}

Beware of tracking user specific information on the server side as it will most likely cause caching problems. Instead, use Javascript to retrieve the user data from a cookie, localStorage or some Ajax request and then push the data to Matomo using either the Chessio_Matomo JS component...

require(['Chessio_Matomo/js/tracker'], function (trackerComponent) {
    trackerComponent.getTracker().done(function (tracker) {
        // Do something with tracker
    });
});

... or the vanilla Matomo approach:

var _paq = _paq || [];
_paq.push(['setDocumentTitle', 'My Custom Title']);

See the Matomo Developer Docs or the \Chessio\Matomo\Model\Tracker source code for a list of all methods available in the Tracking API.

No changelog yet

The vendor hasn't published a changelog. Tagged releases appear in the Versions tab.

Versions
Version Stability QA Status Compatibility Released
2.1.4 stable Fail Partially compatible Details 2023-01-10 22:05:23
2.1.3 stable Not tested Not yet tested Details 2021-07-24 16:20:51
2.1.2 stable Not tested Not yet tested Details 2021-05-02 08:39:35
2.1.1 stable Not tested Not yet tested Details 2021-04-29 18:01:22
2.0.4 stable Not tested Not yet tested Details 2020-06-30 09:22:08
2.0.3 stable Not tested Not yet tested Details 2019-08-23 20:36:57
2.0.2 stable Not tested Not yet tested Details 2018-05-06 19:11:32
2.0.1 stable Not tested Not yet tested Details 2018-03-27 18:59:05
2.0.0 stable Not tested Not yet tested Details 2018-01-28 16:42:12
1.3.1 stable Not tested Not yet tested Details 2017-10-22 14:41:33
1.3.0 stable Not tested Not yet tested Details 2017-03-02 21:22:27
1.2.1 stable Not tested Not yet tested Details 2016-11-17 20:39:27
1.2.0 stable Not tested Not yet tested Details 2016-11-07 16:53:47
1.1.0 stable Not tested Not yet tested Details 2016-02-25 18:56:02
1.0.1 stable Not tested Not yet tested Details 2016-02-09 17:37:40
1.0.0 stable Not tested Not yet tested Details 2016-02-07 18:34:16

Requires 11

Package Constraint
php ~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.1.0|~8.2.0
magento/framework ~101.0|~102.0|~103.0
magento/module-catalog ~102.0|~103.0|~104.0
magento/module-catalog-search ~100.0|~101.0|~102.0
magento/module-checkout ~100.0
magento/module-config ~101.0
magento/module-customer ~101.0|~102.0|~103.0
magento/module-quote ~101.0
magento/module-sales ~101.0|~102.0|~103.0
magento/module-search ~100.0|~101.0
magento/module-store ~100.0|~101.0

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 Pass not tested
2.4.8 not tested not tested
2.4.9 not tested not tested

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Fail 23 4 errors, 19 warnings (ruleset: Magento2) — 2 auto-fixable with phpcbf
PHPMD Warning 6 6 rule violations (MissingImport:3, IfStatementAssignment:1, CyclomaticComplexity:1, NPathComplexity:1)
Cpd Pass 0
Composer validate Pass 0

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 26 N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
AGPL-3.0+
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.