Install the web library
Register the website in Oraami and copy its public site key and collector origin from Settings → Installation. Use one installation per document. Allow the collector in your site’s script-src and connect-src policies.
npm install https://app.oraami.com/downloads/oraami-web-1.0.0.tgzConnect your consent banner
Create oraami-config.js with the two public values. Connect your existing banner’s ready callback and change notification to consent.set. Pass true only for affirmative analytics consent and false for pending, denial and withdrawal. Keep the default denied during server rendering.
import { createConsentState } from '@oraami/web';
export const options = { collector: 'YOUR_COLLECTOR_ORIGIN', siteKey: 'YOUR_PUBLIC_SITE_KEY' };
export const consent = createConsentState();
// In your banner’s ready callback and on every change:
// consent.set(currentAnalyticsChoice === 'granted');Add the tracker to your application
Place the hook in App.svelte or your root src/routes/+layout.svelte. Preserve the existing layout and its children.
<script>
import { useOraami } from '@oraami/web/svelte';
import { options, consent } from './oraami-config.js';
useOraami(options, consent);
</script>Check the first visit
- Open the registered origin. Decline analytics and check that no event or replay uploads start. The tracker script and site configuration may load.
- Grant analytics consent, navigate and open Capture health in Oraami. Check that a new batch was saved for this website.
- Withdraw consent, interact again and verify that new uploads stop. Reload to check the remembered choice.