✦ Cookieless analytics, built around daily rotating IDs
☰
All featuresWeb AnalyticsCustom EventsCookieless AnalyticsIntegrationsPricingDocumentationComparisonsFree toolsBlogGlossary
Installation guide

Install cookieless analytics in React

Initialize one browser SDK instance and track page changes from your router. Use effects for browser work and keep the event names tied to completed product actions.

Prepare the SDK from source

The SDK package is currently private and unpublished. Clone its repository and build the browser bundle. The source repository uses pnpm; application integration examples below use npm. Pin a reviewed commit for a production deployment.

Build the source and a local package archive

git clone https://github.com/yosriady/untitled-analytics-sdk.git
cd untitled-analytics-sdk
pnpm install
pnpm build
pnpm pack

Install with npm in the application

Build the private SDK repository first, then install its archive into your React app.

Application install command

npm install ../untitled-analytics-sdk/untitled-analytics-web-0.1.0.tgz

Share the SDK instance

Use a browser-only singleton with automatic pageviews disabled when a router observer handles page tracking. This avoids recreating the tracker on every render or development effect cycle.

Shared SDK module

// src/lib/analytics.ts
import { createAnalytics } from '@untitled-analytics/web';

let instance: ReturnType<typeof createAnalytics> | undefined;
export function getAnalytics() {
  if (typeof window === 'undefined') return undefined;
  return instance ??= createAnalytics({
    writeKey: 'YOUR_SDK_WRITE_KEY',
    endpoint: 'https://api.your-domain.com',
    autoPageviews: false,
  });
}

Connect to your router

For React Router, mount this component inside your Router. It assumes react-router-dom is already part of your app. For another router, use its equivalent location hook and call page when navigation completes.

React Router observer

import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { getAnalytics } from './lib/analytics';

export function AnalyticsTracker() {
  const { pathname, search } = useLocation();
  useEffect(() => { getAnalytics()?.page(); }, [pathname, search]);
  return null;
}

Track after the action succeeds

Call track in the completion callback for signup, checkout, or an export. Identify with the current account ID after login; clear it after logout. Avoid putting an identify call on a server-rendered module’s top level.

Example completed action

getAnalytics()?.track('report_exported', { format: 'csv' });

Verify pageviews and custom events

Register your actual site origin and use its public SDK write key. The endpoint is your deployed API origin, not a Tinybird URL. Open the published site, check that the bundle loads, and inspect successful collector requests and the project activity feed. Collection is queued, so allow for delivery latency.

Trigger a second page and a custom event. Confirm one expected pageview per navigation. Disable duplicate analytics installations. Identify an account only after login and clear the SDK user ID at logout. Review campaign fields, properties, and optional replay on a non-sensitive page first.

Frequently asked questions

Is the npm package public?

No. Build from source and install the local archive, or host the built browser bundle. Do not assume npm install @untitled-analytics/web resolves yet.

Which endpoint do I use?

Use your deployed analytics API origin, such as https://api.your-domain.com. Do not expose Tinybird or database credentials in browser code.

How do I check installation?

Verify bundle loading and successful collector requests, then inspect the project activity feed for the page and a named test event.

Sources and implementation