> ## Documentation Index
> Fetch the complete documentation index at: https://docs.taap.it/llms.txt
> Use this file to discover all available pages before exploring further.

# Install Radar on a SvelteKit site

> Add the Radar script to a SvelteKit site through src/app.html, or from the root layout with svelte:head when the key comes from an env variable.

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.

```html src/app.html theme={null}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    %sveltekit.head%

    <script
      async
      src="https://taap.it/scripts/tracker.js"
      data-project="pk_xxxx"
      data-track-outbound="true"
      data-track-forms="true"
    ></script>
  </head>
  <body data-sveltekit-preload-data="hover">
    <div style="display: contents">%sveltekit.body%</div>
  </body>
</html>
```

For what each attribute does, see [how the script works](https://docs.taap.it/radar/how-the-script-works.md).

## 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.

```svelte src/routes/+layout.svelte theme={null}
<script lang="ts">
  import { PUBLIC_RADAR_PROJECT_KEY } from "$env/static/public";
</script>

<svelte:head>
  {#if PUBLIC_RADAR_PROJECT_KEY}
    <script
      async
      src="https://taap.it/scripts/tracker.js"
      data-project={PUBLIC_RADAR_PROJECT_KEY}
      data-track-outbound="true"
      data-track-forms="true"
    ></script>
  {/if}
</svelte:head>

<!-- the rest of your layout stays as it is -->
```

## 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.

```bash .env theme={null}
PUBLIC_RADAR_PROJECT_KEY=
```

```bash .env.production theme={null}
PUBLIC_RADAR_PROJECT_KEY=pk_xxxx
```

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](https://docs.taap.it/help/radar/check-your-installation.md). 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.