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

# Install the Datasite tracking script

> Install the Datasite tracker in HTML, Next.js, React, or Vue, configure collection options, and add recording for replay and heatmaps.

Install the Datasite tracking script once in your site's shared document head or root layout. Use the exact script URL and website ID shown on **Settings → Setup**.

## HTML

```html theme={null}
<script defer src="https://app.datasite.sh/script.js"
  data-website-id="YOUR_WEBSITE_ID"></script>
```

## Next.js

```tsx theme={null}
import Script from 'next/script';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          src="https://app.datasite.sh/script.js"
          strategy="afterInteractive"
          data-website-id="YOUR_WEBSITE_ID"
        />
      </body>
    </html>
  );
}
```

## React

Load the script once in the root application component:

```tsx theme={null}
import { useEffect } from 'react';

export function DatasiteAnalytics() {
  useEffect(() => {
    const script = document.createElement('script');
    script.src = 'https://app.datasite.sh/script.js';
    script.defer = true;
    script.setAttribute('data-website-id', 'YOUR_WEBSITE_ID');
    document.head.appendChild(script);

    return () => script.remove();
  }, []);

  return null;
}
```

## Vue

```vue theme={null}
<script setup>
import { onMounted, onUnmounted } from 'vue';

let script;

onMounted(() => {
  script = document.createElement('script');
  script.src = 'https://app.datasite.sh/script.js';
  script.defer = true;
  script.setAttribute('data-website-id', 'YOUR_WEBSITE_ID');
  document.head.appendChild(script);
});

onUnmounted(() => script.remove());
</script>
```

## Options

| Attribute | Use | Default |
| - | - | - |
| `data-website-id` | Identifies the website | Required |
| `data-host-url` | Sends collection requests to another Datasite host | Script origin |
| `data-auto-track="false"` | Disables automatic page views | Automatic tracking on |
| `data-performance="true"` | Collects Web Vitals | Off |
| `data-do-not-track="true"` | Honors the browser Do Not Track signal | Off |
| `data-exclude-search="true"` | Removes query strings from tracked URLs | Off |
| `data-exclude-hash="true"` | Removes URL fragments | Off |
| `data-no-visitor-id="true"` | Disables persistent visitor identity | Off |

## Replay and heatmaps

When either feature is enabled, add the recorder script after the main tracker:

```html theme={null}
<script defer src="https://app.datasite.sh/recorder.js"
  data-website-id="YOUR_WEBSITE_ID"></script>
```

Custom domains or proxy installations may use different asset paths. Always use the URLs shown on **Settings → Setup**.


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