trackrv0.3.0trackr.casoon.de

CASOON Open Source

Know what people read on your site, without collecting who they are.

trackr counts pageviews and events on static sites and single-page apps. A small script in the browser sends them to an endpoint on your own server, which removes personal data before anything is stored, in a database or service you pick.

pnpm add @casoon/trackr
npm install @casoon/trackr
LGPL-3.0-or-laternpm 0.3.0Node 22+
what gets stored · examples/output/event.json
{
  "response": {
    "status": 200,
    "body": "OK"
  },
  "stored": [
    {
      "type": "event",
      "name": "signup_click",
      "url": "/users/[redacted]/settings",
      "props": {
        "plan": "pro",
        "email": "[redacted]",
        "note": "reply to [redacted]",
        "seats": 3
      },
      "ts": 1791961260000,
      "sessionId": "6a903f454a1bbf75",
      "device": "mobile",
      "browser": "Chrome",
      "os": "Android"
    }
  ]
}
gzip size of the browser script (script.js)
870 B
cookies set by the script
0
places to store events: Postgres, webhook, HTTP API, GA4
4
tests in the Vitest suite
73

How it works

You add the script to your site and a small endpoint to your server. Every pageview and every event you track goes to that endpoint first, not to a third party.

The endpoint ignores bots, drops email addresses and similar personal data from URLs and event properties, and keeps no IP address. Then it hands the event to the storage you configured.

How trackr worksThe browser script on your site sends pageviews and events to an endpoint on your own server. The handler there drops bots and personal data and passes the event to the storage you configured: Postgres, a webhook, an HTTP API or GA4. A tracking pixel takes the same path without JavaScript.How trackr worksBrowser script → Handler on your server: pageviews, eventsTracking pixel → Handler on your server: pageviewHandler on your server → Storage you chooseStorage you choose → PostgresStorage you choose → WebhookStorage you choose → HTTP APIStorage you choose → GA4pageviews, eventspageviewBrowser script – on your website, no cookiesBrowser scripton your website, no cookiesTracking pixel – email, no JavaScriptTracking pixelemail, no JavaScriptHandler on your server – removes bots and personal dataHandler on your serverremoves bots and personal dataStorage you choose – one, several, or batchedStorage you chooseone, several, or batchedPostgresPostgresWebhookWebhookHTTP APIHTTP APIGA4 – sent from your serverGA4sent from your server
How trackr worksThe browser script on your site sends pageviews and events to an endpoint on your own server. The handler there drops bots and personal data and passes the event to the storage you configured: Postgres, a webhook, an HTTP API or GA4. A tracking pixel takes the same path without JavaScript.How trackr worksBrowser script → Handler on your server: pageviews, eventsTracking pixel → Handler on your server: pageviewHandler on your server → Storage you chooseStorage you choose → PostgresStorage you choose → WebhookStorage you choose → HTTP APIStorage you choose → GA4pageviews, eventspageviewBrowser script – on your website, no cookiesBrowser scripton your website, no cookiesTracking pixel – email, no JavaScriptTracking pixelemail, no JavaScriptHandler on your server – removes bots and personal dataHandler on your serverremoves bots and personal dataStorage you choose – one, several, or batchedStorage you chooseone, several, or batchedPostgresPostgresWebhookWebhookHTTP APIHTTP APIGA4 – sent from your serverGA4sent from your server
How trackr worksThe browser script on your site sends pageviews and events to an endpoint on your own server. The handler there drops bots and personal data and passes the event to the storage you configured: Postgres, a webhook, an HTTP API or GA4. A tracking pixel takes the same path without JavaScript.How trackr worksBrowser script → Handler on your server: pageviews, eventsTracking pixel → Handler on your server: pageviewHandler on your server → Storage you chooseStorage you choose → PostgresStorage you choose → WebhookStorage you choose → HTTP APIStorage you choose → GA4pageviews, eventspageviewBrowser script – on your website, no cookiesBrowser scripton your website, no cookiesTracking pixel – email, no JavaScriptTracking pixelemail, no JavaScriptHandler on your server – removes bots and personal dataHandler on your serverremoves bots and personal dataStorage you choose – one, several, or batchedStorage you chooseone, several, or batchedPostgresPostgresWebhookWebhookHTTP APIHTTP APIGA4 – sent from your serverGA4sent from your server
How trackr worksThe browser script on your site sends pageviews and events to an endpoint on your own server. The handler there drops bots and personal data and passes the event to the storage you configured: Postgres, a webhook, an HTTP API or GA4. A tracking pixel takes the same path without JavaScript.How trackr worksBrowser script → Handler on your server: pageviews, eventsTracking pixel → Handler on your server: pageviewHandler on your server → Storage you chooseStorage you choose → PostgresStorage you choose → WebhookStorage you choose → HTTP APIStorage you choose → GA4pageviews, eventspageviewBrowser script – on your website, no cookiesBrowser scripton your website, no cookiesTracking pixel – email, no JavaScriptTracking pixelemail, no JavaScriptHandler on your server – removes bots and personal dataHandler on your serverremoves bots and personal dataStorage you choose – one, several, or batchedStorage you chooseone, several, or batchedPostgresPostgresWebhookWebhookHTTP APIHTTP APIGA4 – sent from your serverGA4sent from your server

What it does

  1. For static sites and SPAs

    Works with Astro and any framework whose routes take a web Request and return a Response. Page changes in single-page apps are counted too.

  2. No cookies, no stored IP

    The script stores nothing in the browser. On the server, visits are grouped into a session that starts fresh every day; the IP address itself is never stored.

  3. Your data, your storage

    Keep events in your own Postgres, forward them to a webhook or an HTTP API, or send them to GA4 from your server. You can also combine several.

  4. Works without JavaScript

    A tracking pixel records pageviews in emails and on pages that run no script.

Quickstart

Three steps from install to the first stored pageview. The full walkthrough, with the endpoint and the database table, is in the documentation.

  1. Load the script once in your shared layout and point it at your endpoint.
  2. Add an endpoint that runs createHandler() with a storage adapter.
  3. Create the table with the Postgres migration from the package, or pick another adapter.
Client
import { init } from "@casoon/trackr/client";
init({ endpoint: "/api/track" });