PHPackages                             mnapoli/piwik-twig-extension - 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. [Templating &amp; Views](/categories/templating)
4. /
5. mnapoli/piwik-twig-extension

ActiveLibrary[Templating &amp; Views](/categories/templating)

mnapoli/piwik-twig-extension
============================

This library integrates Matomo into Twig

3.0.0(6y ago)11287.6k↓18.4%31MITPHPPHP &gt;=7.0

Since Sep 16Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mnapoli/MatomoTwigExtension)[ Packagist](https://packagist.org/packages/mnapoli/piwik-twig-extension)[ RSS](/packages/mnapoli-piwik-twig-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (1)

Matomo Twig integration
=======================

[](#matomo-twig-integration)

[![Build Status](https://camo.githubusercontent.com/87d5b281a47c4c6fa0e016cc045356717da8b1b7ed79ac0fa946927375045f3b/68747470733a2f2f7472617669732d63692e636f6d2f6d6e61706f6c692f4d61746f6d6f54776967457874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/mnapoli/MatomoTwigExtension)

This library integrates [Matomo](https://matomo.org//) into [Twig](https://twig.symfony.com/). *Previously named PiwikTwigExtension*.

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

[](#installation)

```
composer require "mnapoli/piwik-twig-extension"

```

Usage
-----

[](#usage)

You have 2 ways to give the Matomo host and site ID:

- When creating the extension (**recommended**)

    ```
    $twig->addExtension(new MatomoTwigExtension('my-matomo-host.com', 123));
    ```

    In the templates, you then just call `{{ matomo() }}`.

    This solution is appropriate in most cases.
- When calling the Twig function

    ```
    $twig->addExtension(new MatomoTwigExtension());
    ```

    In the templates, you have to provide the host and site id: `{{ matomo('my-matomo-host.com', 123) }}`.

    This solution is perfect if you want to be able to customize the site id or Matomo host in the template.

---

Don't forget to add the tracker script at the end of the HTML document, for example:

```
>

        ...

        ...

        {{ matomo() }}

```

### Development environment

[](#development-environment)

In some environments, you want to disable Matomo's tracking (for example on your local machine). That is easily possible by passing `false` for the `$enabled` parameter:

```
$twig->addExtension(new MatomoTwigExtension($host, $siteId, false));
```

License
-------

[](#license)

This library is released under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~682 days

Total

4

Last Release

2215d ago

Major Versions

1.0.0 → 2.0.02019-06-21

2.0.1 → 3.0.02020-04-24

PHP version history (2 changes)1.0.0PHP &gt;=5.4

2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/329a6111724074f5388e95dd41a03ccf3c43f4bfe1ecf27c94c9efc6f7823228?d=identicon)[mnapoli](/maintainers/mnapoli)

---

Top Contributors

[![j0k3r](https://avatars.githubusercontent.com/u/62333?v=4)](https://github.com/j0k3r "j0k3r (13 commits)")[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (6 commits)")[![nicosomb](https://avatars.githubusercontent.com/u/121870?v=4)](https://github.com/nicosomb "nicosomb (3 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mnapoli-piwik-twig-extension/health.svg)

```
[![Health](https://phpackages.com/badges/mnapoli-piwik-twig-extension/health.svg)](https://phpackages.com/packages/mnapoli-piwik-twig-extension)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91492.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36763.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

22046.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

22918.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21914.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
