npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

analytics-plugin-matomo

v1.2.0

Published

Matomo plugin for the analytics module

Readme

Matomo Plugin for analytics

Matomo integration for analytics, a lightweight open-source frontend analytics abstraction layer.

Installation

Install analytics and analytics-plugin-matomo packages.

npm install analytics
npm install analytics-plugin-matomo

Setup

Initialize the plugin with analytics.

import Analytics from 'analytics'
import matomoPlugin from 'analytics-plugin-matomo'

const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    matomoPlugin({
      installationUrl: '/matomo/',
      siteId: 1,
    })
  ]
})

Usage

The plugin loads and configures Matomo's tracking script, then sends data whenever analytics.identify, analytics.page, or analytics.track is called.

If you already include the Matomo tracking script in your templates, remove it to avoid double tracking.

/* Track a page view */
analytics.page()

/* Track a custom event */
analytics.track('Add', {
  category: 'Cart',
  name: 'Ice Cubes',
  value: 3
})

/* Identify a visitor */
analytics.identify('user-id-xyz')

API

Core methods

Plugin methods

paq(...args)

Push a raw command onto Matomo's _paq queue.

analytics.plugins.matomo.paq(['setUserId', 'user-123'])

Configuration

Registration

  • installationUrl — Base URL of your Matomo installation. Used to derive the tracker and script URLs (matomo.php and matomo.js). Required.
  • siteId — Matomo site ID. Required.
  • trackerUrl — Custom tracker endpoint URL. Overrides the value derived from installationUrl. Optional.
  • scriptUrl — Custom tracking script URL. Overrides the value derived from installationUrl. Optional.

Privacy & Cookies

  • requireConsent — Withhold all tracking until consent is granted via updateConsent(). Default: false.
  • requireCookieConsent — Track without cookies until consent is granted via updateConsent(). Default: false.
  • disableCookies — Disable all first-party cookies (cookieless tracking). Default: false.
  • doNotTrack — Respect the browser's Do Not Track setting. Default: false.
  • cookieDomain — Cookie domain, e.g. *.example.com to share cookies across subdomains.
  • secureCookie — Set the Secure flag on all first-party cookies (HTTPS-only sites). Default: false.
  • cookieSameSiteSameSite attribute for tracking cookies: 'Lax' (Matomo default), 'None', or 'Strict'.

Features

  • enableLinkTracking — Track clicks on outbound links and downloads. Default: true.
  • enableHeartBeatTimer — Improve time-on-page accuracy. true uses the Matomo default active time, a number sets the active time in seconds, false disables it. Default: true.
  • enableCrossDomainLinking — Stitch visits across multiple owned domains. Default: false.
  • disablePerformanceTracking — Disable page performance tracking. Default: false.

These cover the most common Matomo settings. For the complete, authoritative list of options and their types, see the config definition in the source: src/types.ts.

Other Matomo settings

The plugin only maps a subset of Matomo's tracking API to config options. For anything not listed above, push the raw command yourself with paq. For example, to set a custom dimension:

analytics.plugins.matomo.paq(['setCustomDimension', 1, 'premium-user'])

Consent Handling

By default, the plugin tracks everything without awaiting consent. Two plugin options change this. Both use the updateConsent method to grant or revoke consent at runtime.

  • No consent (default): leave both options unset. All events are tracked.
  • requireConsent: true: no tracking until consent is granted.
  • requireCookieConsent: true: tracking starts immediately without cookies; cookies are set once consent is granted. Use this for cookieless tracking that adds cookies later for more accurate tracking data.
const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    matomoPlugin({
      requireConsent: true,
    })
  ]
})

// Later... grant consent for tracking from consent dialog
analytics.plugins.matomo.updateConsent(true)

Supported Platforms

The Matomo plugin works in the browser. Node is currently not supported.

License

MIT