# react-matomo

> ## install

Latest version **0.0.6** (published 2022-07-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-matomo
pnpm add react-matomo
yarn add react-matomo
bun add react-matomo
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2022-07-13 |
| First published | 2022-07-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Anthony DI STEFANO |
| Maintainers | madein83 |
| Keywords | react, analytics, matomo, react-matomo |

## Links

- npm: https://www.npmjs.com/package/react-matomo
- Repository: https://github.com/MADEiN83/react-matomo
- Issues: https://github.com/MADEiN83/react-matomo/issues
- npm.io page: https://npm.io/package/react-matomo

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.6 (latest) — 2022-07-13
- 0.0.5 — 2022-07-05
- 0.0.4 — 2022-07-05
- 0.0.3 — 2022-07-05
- 0.0.2 — 2022-07-05
- 0.0.1 — 2022-07-05

## README

# react-matomo

## install

```
npm i -D react-matomo
```

Or using `yarn`:

```
yarn add react-matomo
```

## usage

Setup the Provider:

```ts
import { MatomoProvider, createInstance } from "react-matomo";

<MatomoProvider
  value={createInstance({
    url: "https://analytics.yoursite.org/",
    siteId: 9,
  })}
>
  <App />
</MatomoProvider>;
```

Use the hook:

```ts
import { useMatomo } from "react-matomo";

const App = () => {
  const { trackPageView } = useMatomo();

  useEffect(() => {
    trackPageView();
  }, []);

  return <div>Content goes here</div>;
};
```

Track event

```ts
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`

---
_Source: https://npm.io/package/react-matomo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
