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

# SvelteKit installation

> Install OpenRevenue analytics in SvelteKit through app.html or a layout component.

## Via app.html

The simplest approach: add the script to `src/app.html` before `</body>`:

```html src/app.html theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
<!DOCTYPE html>
<html lang="en">
  <head>%sveltekit.head%</head>
  <body>
    <div>%sveltekit.body%</div>

    <script
      src="https://api.openrevenue.com/tracker.js"
      data-site="your-project-id"
      defer
    ></script>
  </body>
</html>
```

## Via +layout.svelte

To load the tracker from your Svelte component tree, add it in `src/routes/+layout.svelte`:

```svelte src/routes/+layout.svelte theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
<script>
  import { onMount } from "svelte"
  import { page } from "$app/stores"

  onMount(() => {
    const script = document.createElement("script")
    script.src = "https://api.openrevenue.com/tracker.js"
    script.dataset.site = "your-project-id"
    script.defer = true
    document.head.appendChild(script)
  })
</script>

<slot />
```

> [!NOTE]
>
> OpenRevenue's tracker listens to `history.pushState` automatically, so SvelteKit client-side navigation is tracked without extra setup.

## Verify

Deploy and visit your site. Check your [OpenRevenue dashboard](https://www.openrevenue.com/dashboard): a pageview should appear within seconds.

> [!NOTE]
>
> OpenRevenue ignores `localhost` automatically. Always test on your deployed URL.


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