react-matomo
v0.0.6
Published
## install
Maintainers
Readme
react-matomo
install
npm i -D react-matomoOr using yarn:
yarn add react-matomousage
Setup the Provider:
import { MatomoProvider, createInstance } from "react-matomo";
<MatomoProvider
value={createInstance({
url: "https://analytics.yoursite.org/",
siteId: 9,
})}
>
<App />
</MatomoProvider>;Use the hook:
import { useMatomo } from "react-matomo";
const App = () => {
const { trackPageView } = useMatomo();
useEffect(() => {
trackPageView();
}, []);
return <div>Content goes here</div>;
};Track event
import { useMatomo } from "react-matomo";
const App = () => {
const { trackEvent } = useMatomo();
return (
<div>
<button onClick={() => trackEvent("category", "action")}>Click me</button>
</div>
);
};roadmap
- [ ] handle custom configuration
- [x] handle
trackEvent - [ ] handle
trackSiteSearch - [ ] handle
trackGoal - [ ] handle
trackLink
