Skip to main content
In a SvelteKit project, the simplest way to install Radar is to paste the script into src/app.html, the HTML template of every page. Replace pk_xxxx with your project key.
src/app.html
For what each attribute does, see how the script works.

Alternative: svelte:head in the root layout

Use this version when you want to read the project key from an environment variable. The {#if} block skips the script when the key is empty. It sits inside <svelte:head>, because Svelte does not allow <svelte:head> inside a block.
src/routes/+layout.svelte

Keep the key out of development

With the layout version, store the key in an environment file and leave it empty for development. Without a key, the script is not added to the page, so Radar does not load while you develop.
SvelteKit only exposes variables whose name starts with PUBLIC_ to the browser, through $env/static/public. Keep the empty line in .env: the import fails at build time if the variable is not declared at all.

Check that it works

Deploy your site, open the published version, load two pages and click a link. The first event should reach your Radar dashboard within a few seconds. If nothing arrives, follow check your installation. When the tag is added by JavaScript rather than written in the HTML, it does not show in the raw page source: look for tracker.js in the Elements panel of your browser’s developer tools instead.