Skip to main content
The Klaritics Web SDK sends analytics events directly from the browser to your self-hosted Klaritics instance. You can install it via npm for bundler-based projects or load it from a CDN script tag for simpler setups. This guide covers installation, initialization, event logging, user and session management, and SPA behavior.

Installation

Install the package from npm:
Then import and initialize:

Initialization options

You can pass additional options when calling init:

Logging events

Use logEvent to send standard analytics events. Use logClientEvent for events that are specific to your client-side logic.

User and session management

Single-page applications

For SPAs, you can use your existing redirection handler to trigger events on route changes. URL-based page tracking is configured from the Klaritics dashboard and does not require additional SDK setup.