Getting Started
Install the SDK and initialize it in your app.
Installation
npm
bash npm install @omni-analytics/sdk Basic setup
Call initializeSDK() once, as early as possible in your app.
import { initializeSDK } from "@omni-analytics/sdk";
initializeSDK({
projectId: "your-project-id",
endpoint: "https://omnioptimize-vdvv.onrender.com/ingest",
writeKey: "omni-public-write-key-here", // Required — get from dashboard
replay: {
enabled: true, //enables session replay
},
});- session replays are not by default so enable if if needed.
That’s it. The SDK will now track page views, clicks, and sessions automatically.
The writeKey authenticates your events. Get it from your project settings.
Disable tracking in development
You probably don’t want to track local development activity. Disable it:
initializeSDK({
projectId: "your-project-id",
endpoint: "https://omnioptimize-vdvv.onrender.com/ingest",
writeKey: "omni-public-write-key-here",
enabled: process.env.NODE_ENV === "production", // Only track in production
});When enabled: false, the SDK stops all tracking—no clicks, no page views, no recordings.
Next.js (App Router)
Initialize in your root layout:
// app/layout.tsx
import { initializeSDK } from "@omni-analytics/sdk";
initializeSDK({
projectId: "your-project-id",
endpoint: "https://omnioptimize-vdvv.onrender.com/ingest",
writeKey: "omni-public-write-key-here",
enabled: process.env.NODE_ENV === "production",
});
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}React SPA
Initialize at your app entry point:
// main.tsx
import React from "react";
import ReactDOM from "react-dom/client";
import { initializeSDK } from "@omni-analytics/sdk";
import App from "./App";
initializeSDK({
projectId: "your-project-id",
endpoint: "https://omnioptimize-vdvv.onrender.com/ingest",
writeKey: "omni-public-write-key-here",
});
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
);Configuration options
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
projectId | string | Yes | — | Your project ID (from dashboard) |
endpoint | string | Yes | — | Event ingestion endpoint |
writeKey | string | Yes | — | Authentication key (from dashboard) |
enabled | boolean | No | true | Enable or disable tracking |
batchSize | number | No | 30 | Number of events to batch before sending |
batchTimeout | number | No | 2000 | Milliseconds to wait before flushing incomplete batch |
replay.enabled | boolean | No | true | Enable session replay recordings |
Verify it’s working
After initialization, check your browser’s network tab. You should see
requests to your endpoint with batched events.
If events aren’t appearing:
- Double-check your
projectId,endpoint, andwriteKey - Make sure
enabledisn’t set tofalse - Check the browser console for errors
- Disable any ad blockers that might block analytics requests
Last updated on