Allows including the Matomo Tracking or the Matomo Tag Manager with JavaScript.
This library is made for the use with Node. Add it to your project by running $ npm install bitandblack-matomo-tracking
. You can of course also use an alternative to NPM.
Import the Matomo Tracker and initialize it like that:
import { MatomoTracking } from "bitandblack-matomo-tracking";
const matomoTracking = new MatomoTracking(
99,
"https://www.yoursite.com/matomo",
{
trackPageView: true,
enableLinkTracking: true
}
);
The parameters are:
- The page id. This one is required.
- The URL of your Matomo instance. This one is also required.
- Tracking options. These are optional.
Note: You don't need to add piwik.php
or matomo.php
in the url.
Import the Matomo Tag Manager and initialize it like that:
import { MatomoTagManager } from "bitandblack-matomo-tracking";
const matomoTagManager = new MatomoTagManager(
"container_Yolo25",
"https://www.yoursite.com/matomo"
);
The parameters are:
- The container id. This one is required.
- The URL of your Matomo instance. This one is also required.
- Tracking options. These are optional.
If you have any questions feel free to contact us under hello@bitandblack.com
.
Further information about Bit&Black can be found under www.bitandblack.com.