0.5.1 • Published 2 years ago

matomo-router5-plugin v0.5.1

Weekly downloads
56
License
MIT
Repository
github
Last release
2 years ago

matomo-router5-plugin   npm version npm bundle size

Description

Matomo (formerly Piwik) integration with router5.

How does it work?

matomo-router5-plugin will send tracking data when router5 triggers onTransitionSuccess. Custom tracking is also available when needed.

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 || ^8.0.0

Installation

npm install --save matomo-router5-plugin

Usage

initialize as router5 plugin

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, default `[]`. Additional tracking features.
  usePiwik: true, // Optional, default `true`. Set to `true` to use `piwik.js` and `piwik.php`; else use `matomo.js` and `matomo.php`.
};

router.usePlugin(matomoPlugin(matomoOptions));

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

features: [
  ["setUserId", () => user ? user.name : "Anonymous User"]
]

custom tracking

import { track } from "matomo-router5-plugin";

track({
  customUrl: "custom url", // Optional.
  referrerUrl: "custom referrer url", // Optional.
  documentTitle: "custom doc title", // Optional.
  features: [], // Optional. Additional tracking features.
});
0.5.0

2 years ago

0.5.1

2 years ago

0.4.0

3 years ago

0.3.0

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago