---
title: "Install the tracking script"
description: "Add the Otus tracking snippet to the head of your website to start collecting data."
canonical_url: "https://docs.otusanalytics.com/getting-started/install-script"
---

> Index of every page on this site: [llms.txt](https://docs.otusanalytics.com/llms.txt)

Otus collects data through a single lightweight script. Add it once to every page you want to measure. The best place is inside the `<head>` so it loads early.

## Add the snippet

Copy your snippet from **Site settings → Tracking snippet** and paste it just before the closing `</head>` tag:

```html [index.html]
<!doctype html>
<html>
  <head>
    <!-- ... your other head tags ... -->
    <script async src="https://cdn.otusanalytics.com/otusanalytics/otus.js"></script>
    <script>
      window.otus=window.otus||function(){(otus.q=otus.q||[]).push(arguments)},otus.init=otus.init||function(i){otus.o=i||{}};
      otus.init({ siteId: 123, endpoint: "https://ingest.otusanalytics.com/e" })
    </script>
  </head>
  <body>
    <!-- ... -->
  </body>
</html>
```

Replace `siteId: 123` with **your** site ID. Everything else can stay as-is.

The first line loads the tracker. The second defines `otus()` right away, so calls like `otus('track', ...)` or `otus('setConsent', ...)` work anywhere on the page, even before the tracker has finished loading: they're queued and sent once it has.

<callout icon="i-lucide-zap">

The script loads `async` and is under 4 KB, so it won't block rendering or slow your page down.

</callout>

## Options

Pass these to `otus.init({ ... })`:

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Required
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        siteId
      </code>
    </td>
    
    <td>
      Yes
    </td>
    
    <td>
      Your numeric site ID. Without it, tracking is skipped.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        endpoint
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      Ingestion URL. Defaults to <code>
        https://ingest.otusanalytics.com/e
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trackingMode
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      <code>
        "cookieless"
      </code>
      
       (default) or <code>
        "full"
      </code>
      
      . See <a href="/getting-started/tracking-modes">
        Tracking modes
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        hash
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      <code>
        true
      </code>
      
       for hash-based routing (<code>
        /#/about
      </code>
      
      ), see <a href="#single-page-apps-spas">
        Single-page apps
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        consentDefault
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      <code>
        "granted"
      </code>
      
       to treat unanswered consent as granted, for sites that don't need a consent banner. See <a href="/events-goals/tracking-api#setconsent">
        consent
      </a>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        consentWait
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      Hold the first pageview up to this many milliseconds (max 10000) for your consent banner to call <code>
        otus('setConsent', ...)
      </code>
      
      .
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        trackLocalhost
      </code>
    </td>
    
    <td>
      No
    </td>
    
    <td>
      <code>
        true
      </code>
      
       to also track visits on <code>
        localhost
      </code>
      
      , for testing.
    </td>
  </tr>
</tbody>
</table>

## Enabling full tracking

Cookieless is the default. To enable [full tracking](https://docs.otusanalytics.com/getting-started/tracking-modes) (which enables returning-visitor metrics), add `trackingMode: "full"`:

```js
otus.init({ siteId: 123, endpoint: "https://ingest.otusanalytics.com/e", trackingMode: "full" })
```

## Single-page apps (SPAs)

You don't need to do anything extra. The tracker automatically records a pageview on the initial load **and** on every client-side route change to a new path (`pushState` and back/forward navigation), so frameworks like Vue, React, Svelte and Angular work out of the box. Query-string changes, `#anchor` links and redirects via `replaceState` aren't counted as new pageviews.

If your app uses hash-based routing (URLs like `/#/about`), add `hash: true` to `otus.init()`. Hash changes are then tracked as pageviews, with the hash included in the page path.

## Opting yourself out

To stop the tracker recording your own visits in a browser, run this in the console once:

```js
document.cookie = "otus_ignore=true; domain=example.com; path=/; max-age=34128000";
```

Replace `example.com` with your own domain (without `www.`), so the opt-out applies to all your subdomains.

## Next step

Once the snippet is live, [verify your installation](https://docs.otusanalytics.com/getting-started/verify-installation). Using a tag manager or CMS instead? See the [integration guides](https://docs.otusanalytics.com/integrations).

## Sitemap

See the full [sitemap](https://docs.otusanalytics.com/sitemap.md) for all pages.
