Skip to main content

Migration Guide

From react-matomo

The older react-matomo uses a different API.

In this library:

✅ You do NOT need createInstance()
✅ You use <MatomoProvider>
✅ You use useTrack() instead of trackEvent()

Example:

Old:

instance.trackEvent("Cat", "Click", "My Cat", 1);

New:

const { track } = useTrack();

track("cat.click", {
name: "My Cat",
value: 1,
});

From raw _paq.push()

Old:

_paq.push(["trackEvent", "Cat", "Click", "My Cat", 1]);

New:

const { track } = useTrack();

track("cat.click", {
name: "My Cat",
value: 1,
});