Skip to content

Use the JavaScript tracker package

Load the browser tracker from application code with the typed JavaScript wrapper.

Use @supermetry/tracker when your application should load and call the tracker through TypeScript.

  1. Clone the source beside your application and add the package with Bun.

    Terminal window
    git clone https://github.com/velixio/supermetry.git
    bun add ./supermetry/sdk/js
  2. Initialize it in browser code with the generated site-script URL.

    import { init } from "@supermetry/tracker";
    const tracker = init({
    site: "YOUR_SITE_ID",
    src: "https://analytics.example.com/js/YOUR_SITE_ID.js",
    hash: true,
    consent: true,
    });
    tracker.consent(true);
    tracker.track("Signup", { plan: "pro" });

Calls made while the script loads are queued. During server rendering, init() returns safe no-op methods and does not access the DOM.

What you should see: Signup appears under Events after consent is granted and the script loads.