Install Simple Analytics with React edit

Add Simple Analytics to React apps with our official React package.

Install

Run this command to install Simple Analytics for React:

npm i @simpleanalytics/react

Usage

Import the <SimpleAnalytics /> to start tracking pageviews

import { SimpleAnalytics } from "@simpleanalytics/react";

export function App() {
  return (
    <>
      {/* your app */}
      <SimpleAnalytics />
    </>
  );
}

Options

<SimpleAnalytics domain="custom.domain.com" />

Send events

import { trackEvent } from "@simpleanalytics/react";

function Button() {
  return (
    <button onClick={() => trackEvent("clicked")}>
      Track event
    </button>
  );
}

Note: trackEvent requires <SimpleAnalytics /> to be present in your app.

If you encounter issues, don’t hesitate to contact us via our support channels.