Skip to Content
🎉 OmniOptimize SDK v0.3.0 released - Check out the new features!
Getting Started

Getting Started

Install the SDK and initialize it in your app.

Installation

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

ParameterTypeRequiredDefaultDescription
projectIdstringYes—Your project ID (from dashboard)
endpointstringYes—Event ingestion endpoint
writeKeystringYes—Authentication key (from dashboard)
enabledbooleanNotrueEnable or disable tracking
batchSizenumberNo30Number of events to batch before sending
batchTimeoutnumberNo2000Milliseconds to wait before flushing incomplete batch
replay.enabledbooleanNotrueEnable 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, and writeKey
  • Make sure enabled isn’t set to false
  • Check the browser console for errors
  • Disable any ad blockers that might block analytics requests
Last updated on