GuidesWeb

React analytics, cookieless and hosted in Germany

Cookieless product analytics for React SPAs, with event data stored in Germany.

Privytics tracks page views, custom events and user profiles in a React single page app using the open source @openpanel/web SDK. You create one OpenPanel instance, point apiUrl at Privytics, and import it wherever you need to send an event. There is no provider to wrap your tree in and no router integration to write: client side navigations are picked up automatically.

Why React teams use Privytics

Route changes are tracked without a router plugin

With trackScreenViews enabled the SDK wraps history.pushState and history.replaceState and listens for popstate, so navigations from React Router, TanStack Router or any other client side router register as screen views. If you use a hash based router, set trackHashChanges to true.

No cookies, so nothing to gate behind a consent banner

Privytics is cookieless by default and writes nothing to the device. The anonymous visitor id is computed server side and resets every day. That means no conditional init inside a useEffect waiting for consent state, and no cookie code paths in your app shell.

One instance, no context provider, no re-renders

@openpanel/web exports a plain class, not a React binding. You export a single op instance from a module and import it in components, event handlers, route loaders or plain utility functions. Nothing is held in React state, so tracking never triggers a render.

Click tracking straight from JSX attributes

With trackAttributes enabled you can add data-track to a button or link in your JSX and pass properties as data-* attributes instead of writing an onClick handler for every element you want to measure.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Install the SDK

    React SPAs use the web SDK directly. There is no separate React package.

    npm install @openpanel/web
  2. Create a shared instance

    Point apiUrl at Privytics. Without it the SDK sends events to OpenPanel's own hosted API. trackScreenViews, trackOutgoingLinks and trackAttributes all default to false, so set the ones you want explicitly; add trackHashChanges: true if you use a hash based router.

    // src/openpanel.ts
    import { OpenPanel } from '@openpanel/web';
    
    export const op = new OpenPanel({
      clientId: 'YOUR_CLIENT_ID',
      apiUrl: 'https://api.privytics.com',
      trackScreenViews: true,
      trackOutgoingLinks: true,
      trackAttributes: true,
    });
  3. Track an event

    Import the instance anywhere and call op.track with an event name and optional properties.

    import { useEffect } from 'react';
    import { op } from '@/openpanel';
    
    function SignupButton() {
      useEffect(() => {
        op.track('my_event', { foo: 'bar' });
      }, []);
    
      return (
        <button
          type="button"
          onClick={() => op.track('button_click', { button: 'signup' })}
        >
          Sign up
        </button>
      );
    }
  4. Identify signed in users

    Optional. Passing your own user id as profileId links sessions into one profile. Call op.clear() on logout to drop the current user and group.

    import { op } from '@/openpanel';
    
    function LoginComponent({ user }: { user: User }) {
      const handleLogin = () => {
        op.identify({
          profileId: user.id, // Required
          firstName: user.firstName,
          lastName: user.lastName,
          email: user.email,
          properties: {
            tier: 'premium',
          },
        });
      };
    
      return (
        <button type="button" onClick={handleLogin}>
          Login
        </button>
      );
    }

Privytics runs the open-source OpenPanel engine, so the upstream React SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

Is there an @openpanel/react package?

No. The npm registry returns 404 for @openpanel/react, and the upstream docs say React SPAs can use @openpanel/web directly with no separate React SDK. You install @openpanel/web and use the OpenPanel class.

Does React analytics with Privytics use cookies?

No. Privytics is cookieless by default and stores nothing on the device. Visitors are counted with a salted hash of IP, user agent and project id, and the salt rotates on a daily schedule.

Will it track React Router page views automatically?

Yes, when trackScreenViews is enabled. The SDK wraps history.pushState and history.replaceState and listens for popstate, which covers client side navigation in the common React routers. Hash based routers need trackHashChanges: true.

Do I need to call trackScreenViews() myself?

No. Passing trackScreenViews, trackOutgoingLinks or trackAttributes to the constructor wires up the listeners during init, and an initial screen view is sent automatically. There is nothing to call in a useEffect.

Where is the event data stored?

Event data is stored in EU data centres in Germany. You remain the data controller for anything you send, including any user id you pass to identify().