Skip to content
Matomo (formerly Piwik) integration with router5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
CHANGELOG.md
LICENSE
README.md
babel.config.js
package-lock.json
package.json
plugin.json
webpack.config.js

README.md

matomo-router5-plugin

Description

Matomo (formerly Piwik) integration with router5.

How does it work?

matomo-router5-plugin will send tracking data when router5 triggers onTransitionSuccess.

What does it track?

There are a lot of tracking features in matomo, here are the default ones for this package.

  • setDocumentTitle - 'from' state name as document title
  • setReferrerUrl - 'from' state path
  • setCustomUrl - 'to' state path
  • outlinks and downloads
  • page generation time

Matomo requirements

  • matomo >= 3.0.2

NPM peer dependencies

  • router5 ^7.0.0

Installation

npm install --save matomo-router5-plugin

Usage

for additional tracking features, see matomo guide. These features will be tracked along with default tracking features.

import matomoPlugin from "matomo-router5-plugin";

const router = createRouter();

const matomoOptions = {
  trackerUrl: "https://matomo.siteurl.com", // Required.
  siteId: 1, // Required.
  features: [] // Optional. Additional tracking features.
};

router.usePlugin(matomoPlugin(matomoOptions));

You can pass in a function as tracking feature (since 0.2.0). The function will be evaluated at time of tracking.

features: [
  ["setUserId", () => user ? user.name : "Anonymous User"]
]
You can’t perform that action at this time.