Install on Next.js and React
Use Next.js's Script component in the root layout for App Router, or _document.tsx for Pages Router.
Draft — for review.
On Next.js, the right place for the Seena widget is the root layout (App Router) or _document.tsx (Pages Router) — whichever renders into every page's <head>. Using Next's built-in <Script> component gives you better loading behavior than a raw <script> tag.
Next.js App Router
Open your root layout (usually src/app/layout.tsx) and add the Script import alongside your existing imports:
import Script from 'next/script';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://app.seenalabs.io/widget/seena.js"
data-site-id="YOUR_SITE_ID"
strategy="afterInteractive"
/>
</body>
</html>
);
}
Why strategy="afterInteractive"? It loads the widget after your page becomes interactive — fast enough to capture sessions, late enough that it doesn't compete with your critical render path. This is the same strategy the Seena Labs marketing site uses on itself.
Next.js Pages Router
Open pages/_document.tsx (or create one if you don't have it) and add the script in the Head:
import { Html, Head, Main, NextScript } from 'next/document';
export default function Document() {
return (
<Html lang="en">
<Head>
<script
src="https://app.seenalabs.io/widget/seena.js"
data-site-id="YOUR_SITE_ID"
async
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
_document.tsx only renders once per full page load, which matches what we want for the widget.
Plain React (Create React App, Vite, etc.)
If you're not on Next.js, just add the script tag to public/index.html (CRA) or index.html (Vite) in the <head>, the same way you would for a plain HTML site:
<script
src="https://app.seenalabs.io/widget/seena.js"
data-site-id="YOUR_SITE_ID"
async
></script>
Don't load it from inside a component — if React re-mounts the component, the widget will try to initialize twice and log a warning.
TypeScript — avoiding the data-site-id lint warning
TypeScript's React types don't type data-site-id as a known attribute; most linters are fine with it, but if yours complains, you can cast:
<Script
src="https://app.seenalabs.io/widget/seena.js"
{...({ 'data-site-id': 'YOUR_SITE_ID' } as any)}
strategy="afterInteractive"
/>
Or use the lowercase-hyphen form directly, which is standard HTML.
Visitor consent
Seena works without cookies for every visitor by default. No device storage happens until a visitor opts in to enhanced analytics. The one exception is Seena's own banner, which stores only the visitor's choice. Choose where the opt-in comes from in the analytics agent's setup, under Visitor consent: "Use my cookie banner", "Use Seena's banner" or "Cookie-less only".
-
Use my cookie banner. Seena reads Google Consent Mode v2, IAB TCF v2.2, OneTrust and Cookiebot automatically. If your banner is something else, call
Seena.consent.grant()andSeena.consent.revoke()from its callback. Go through theSeenaReadyqueue, so the call works even if the script hasn't loaded yet:export function onBannerChoice(accepted: boolean) { const w = window as unknown as { SeenaReady?: Array<() => void> | { push(cb: () => void): void }; Seena?: { consent: { grant(): void; revoke(): void } }; }; w.SeenaReady = w.SeenaReady || []; w.SeenaReady.push(() => { if (accepted) w.Seena?.consent.grant(); else w.Seena?.consent.revoke(); }); } -
Use Seena's banner. Seena shows a small banner at the bottom edge of the page. It stores only the visitor's choice. Add a "Privacy" link that calls
open()so visitors can reopen the banner and change their choice:export function openSeenaPrivacy() { const w = window as unknown as { Seena?: { consent: { open(): void } } }; w.Seena?.consent.open(); } -
Cookie-less only. Seena never asks and stores nothing on the device.
On a site that uses your cookie banner, the script tag can carry data-seena-consent="required". It makes Seena start without cookies and wait for your banner. It is optional, and it only makes Seena stricter, never looser. The snippet the dashboard gives you for a site on "Use my cookie banner" includes it. If you installed earlier, Seena still follows your setting without it. With <Script>, pass it like any other attribute:
<Script
src="https://app.seenalabs.io/widget/seena.js"
data-site-id="YOUR_SITE_ID"
data-seena-consent="required"
strategy="afterInteractive"
/>
Seena honours Global Privacy Control. For the four consent managers Seena reads automatically, when the browser sends it, a consent the manager stored earlier or granted by default isn't enough, and Seena waits for a fresh choice the visitor makes on that page. If you call Seena.consent.grant() yourself, Seena treats it as the visitor's choice, so your banner should apply Global Privacy Control before it calls. A visitor's earlier Allow on Seena's own banner is remembered even when the browser sends it, because it was an explicit click.
What to do next
- Quickstart — confirm everything is wired up.
- How Interview Agents work — including how to pass
userand session metadata.