# chessio/module-matomo

> Matomo Analytics module for Magento 2

`composer require chessio/module-matomo`

Canonical URL: https://packagento.com/chessio/module-matomo

## At a glance

- **Vendor**: chessio (https://packagento.com/chessio.md)
- **Latest version**: 2.1.4 — released 2023-01-10
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/chessio/module-matomo and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require chessio/module-matomo:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

Matomo Analytics module for Magento 2

## README

*Chessio_Matomo* is a [Matomo](https://matomo.org/) web analytics module for the [Magento 2](https://magento.com/) 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*](https://packagist.org/packages/henhed/module-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](https://github.com/fnogatz/magento2-matomo/releases). For installation using [Composer](https://getcomposer.org/), 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](https://github.com/fnogatz/magento2-matomo/archive/main.zip) and move the extracted folder to *app/code/Chessio/Matomo* in your Magento 2 installation directory.

```sh
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*.

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

Or, if you prefer, install it using [Composer](https://getcomposer.org/).

```sh
composer require chessio/module-matomo
```

Finally, enable the module with the Magento CLI tool.

```sh
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.

```php
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.

```php
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...

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

... or the vanilla Matomo approach:

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

See the [Matomo Developer Docs](https://developer.matomo.org/api-reference/tracking-javascript) or the [\Chessio\Matomo\Model\Tracker](https://github.com/fnogatz/magento2-matomo/blob/main/Model/Tracker.php) source code for a list of all methods available in the Tracking API.

## Recent Versions

| Version | Released |
|---|---|
| 2.1.4 | 2023-01-10 |
| 2.1.3 | 2021-07-24 |
| 2.1.2 | 2021-05-02 |
| 2.1.1 | 2021-04-29 |
| 2.0.4 | 2020-06-30 |
| 2.0.3 | 2019-08-23 |
| 2.0.2 | 2018-05-06 |
| 2.0.1 | 2018-03-27 |
| 2.0.0 | 2018-01-28 |
| 1.3.1 | 2017-10-22 |

Showing 10 of 16 versions. Full release history on https://packagento.com/chessio/module-matomo.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| 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 |
| php | ~7.0.0\|~7.1.0\|~7.2.0\|~7.3.0\|~7.4.0\|~8.1.0\|~8.2.0 |

## Quality

Latest release (2.1.4) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| 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. Never affect the Compatibility verdict — 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.

| 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 against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| 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 per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| 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

| 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

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["chessio/module-matomo"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

chessio is a Magento 2 vendor on Packagento. See https://packagento.com/chessio.md for their full catalogue.

