Matomo Plugin

by jdraserschieb

Matomo plugin triggers pageview event on contentReplaced (on each page change). Note that this event is not triggered at the first load, so the first page view must be triggered elsewhere. However, page view event is by default triggered in Javascripts tracking snippet used for embedding Matomo. Simplified code run by this plugin on contentReplaced event:

_paq.push(['setDocumentTitle', document.title]);
_paq.push(['setCustomUrl', window.location.pathname +]);


This plugin can be installed with npm

npm install @swup/matomo-plugin

and included with import

import SwupMatomoPlugin from '@swup/matomo-plugin';

or included from the dist folder

<script src="./dist/SwupMatomoPlugin.js"></script>


To run this plugin, include an instance in the swup options.

const swup = new Swup({
  plugins: [new SwupMatomoPlugin()]