GuidesWeb

JavaScript analytics, cookieless and EU-hosted by default

Cookieless JavaScript analytics, EU-hosted, running in a few lines of code.

Privytics tracks page views, custom events and user profiles in any JavaScript application, whether it is a plain HTML page or a bundled single page app. You install the @openpanel/web package, point it at the Privytics ingestion API with apiUrl, and call op.track() wherever something interesting happens. Event data is stored in Germany, and the tracker sets no cookies.

Why JavaScript teams use Privytics

No cookies, nothing stored on the device

The browser tracker does not set cookies and writes nothing to the visitor's device. Visitors are counted with an anonymous id that resets every day rather than a persistent identifier. You remain the data controller and decide what your own consent notice says.

Screen views work in single page apps

Set trackScreenViews: true and the SDK records a screen view on history navigation, so client side route changes in React, Vue, Svelte or vanilla routers are captured without wiring anything into your router.

Track clicks straight from HTML

With trackAttributes: true you add data-track="my_event" and data-* properties to any element and the SDK fires the event. Useful for marketing pages and server rendered templates where you do not want to ship extra JavaScript per button.

Session replay from the same SDK

Enable replay per project on a paid plan with sessionReplay: { enabled: true }. Text and inputs are masked by default, and you can widen or narrow what is hidden with maskTextSelector and blockSelector rather than adding a second vendor script.

Set it up

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

  1. Install the SDK

    Privytics runs the open source OpenPanel engine, so you use OpenPanel's official npm package.

    npm install @openpanel/web
  2. Initialise the client

    Set apiUrl so the SDK sends events to the Privytics ingestion API instead of the upstream default host.

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

    The first argument is the event name, the second is an optional properties object.

    // main.ts
    import { op } from './op.js';
    
    op.track('my_event', { foo: 'bar' });
  4. Identify a signed in user

    Optional. Call identify() with your own user id to get profiles that join sessions together. profileId is the only required field. This is opt in and needs your own lawful basis.

    import { op } from './op.js';
    
    op.identify({
      profileId: '123', // Required
      firstName: 'Joe',
      lastName: 'Doe',
      email: 'joe@doe.com',
      properties: {
        tier: 'premium',
      },
    });
  5. Or drop in a script tag, with no build step

    If you are not running a bundler, paste this into the <head> of your HTML instead of installing the package. The first block queues calls until the tracker loads, the second loads it. apiUrl still points ingestion at Privytics.

    <script>
      window.op = window.op || function (...args) { (window.op.q = window.op.q || []).push(args); };
      window.op('init', {
        apiUrl: 'https://api.privytics.com',
        clientId: 'YOUR_CLIENT_ID',
        trackScreenViews: true,
        trackOutgoingLinks: true,
      });
    </script>
    <script src="https://privytics.com/op1.js" defer></script>

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

Questions

Does Privytics use cookies for JavaScript tracking?

No. The browser tracker sets no cookies and stores nothing on the device. Repeat visits are matched with a rotating salted hash rather than a persistent identifier stored in the browser.

Why is the npm package called @openpanel/web and not @privytics?

Privytics is built on the open source OpenPanel engine and uses OpenPanel's official SDK packages unchanged. You set apiUrl to https://api.privytics.com so events reach us instead of the upstream default host. Privytics is independent and not affiliated with or endorsed by OpenPanel.

How do I track page views in a React or Vue single page app?

Pass trackScreenViews: true when you initialise the SDK. It listens for history navigation and records a screen view on each route change, so you do not need to hook into your router.

Do I need a client secret in browser code?

No. clientSecret is only required for server side events. Browser setups use clientId alone, which is safe to ship in your frontend bundle.

Can I use Privytics without npm or a build step?

Yes. Paste the script tag snippet into the <head> of your HTML and you are done. It loads the tracker from https://privytics.com/op1.js and takes the same options as the npm setup, so plain HTML pages and server rendered templates need no bundler at all.

What else can the SDK do besides track and identify?

The underlying SDK also documents setGlobalProperties, increment, decrement, clear, upsertGroup, setGroup and setGroups. See the OpenPanel JavaScript SDK reference for the full API surface.