0.0.6 • Published 2 years ago

react-matomo v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-matomo

install

npm i -D react-matomo

Or using yarn:

yarn add react-matomo

usage

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
  • handle trackEvent
  • handle trackSiteSearch
  • handle trackGoal
  • handle trackLink
0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago