﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
title: Installation Guides
description: "Install the Clics tracking script on HTML, Next.js, React, Astro, WordPress, Webflow, and more: under 5 KB, no cookies."
sidebar:
  label: Installation Guides
seo:
  title: Install the Clics cookieless tracking script
---

Install the Clics tracker to collect pageviews and custom events. The script is required for all setups. Pick your stack below.

## AI crawler tracking

AI crawler analytics uses a separate server-side package and project-scoped crawler token. Follow the [AI crawler tracking installation guide](/installation-guides/ai-crawler-tracking) for Next.js, TanStack Start, Hono, Express, Cloudflare, and generic Fetch handlers.

## Before you start

1. Create a project in the [Clics dashboard](https://platform.clics.dev)
2. Copy your **project ID** from **Configure → Tracking**
3. Add your production domain in project settings (or enable localhost for development)

## Script attributes

| Attribute              | Required | Description                                   |
| ---------------------- | -------- | --------------------------------------------- |
| `data-project-id`      | Yes      | Your Clics project ID                         |
| `data-allow-localhost` | No       | Allow tracking on `localhost` and `127.0.0.1` |
| `src`                  | Yes      | `https://clics.dev/tracker.js`                |

## Next.js

Add the Clics client-side tracker with `next/script` in your root layout.

```tsx
import Script from "next/script"

export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode
}>) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          strategy="afterInteractive"
          src="https://clics.dev/tracker.js"
          data-project-id="YOUR_PROJECT_ID"
        />
      </body>
    </html>
  )
}
```

For local development, add `data-allow-localhost` to the `Script` component.

## React

Add the script to your HTML shell (for example `index.html`):

```html
<script
  defer
  data-project-id="YOUR_PROJECT_ID"
  src="https://clics.dev/tracker.js"
></script>
```

For local development, add `data-allow-localhost` to the script tag.

## Astro

Add an inline script in your layout so Astro passes the remote URL through without bundling it:

```html
<script
  is:inline
  defer
  data-project-id="YOUR_PROJECT_ID"
  src="https://clics.dev/tracker.js"
></script>
```

For local development, add `data-allow-localhost`.

## TanStack Start

Add the tracker in your root route's `shellComponent`, after `<Scripts />`:

```tsx
import { HeadContent, Scripts, createRootRoute } from "@tanstack/react-router"

export const Route = createRootRoute({
  // ...
  shellComponent: RootDocument,
})

function RootDocument({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        <HeadContent />
      </head>
      <body>
        {children}
        <Scripts />
        <script
          defer
          src="https://clics.dev/tracker.js"
          data-project-id="YOUR_PROJECT_ID"
        />
      </body>
    </html>
  )
}
```

For local development, add `data-allow-localhost` to the script tag.

## HTML (`<head>`)

Add the Clics tracker to your site's `<head>` the same way you would add Google Analytics or any other JavaScript:

```html
<script
  defer
  data-project-id="YOUR_PROJECT_ID"
  src="https://clics.dev/tracker.js"
></script>
```

For local development:

```html
<script
  defer
  data-project-id="YOUR_PROJECT_ID"
  data-allow-localhost
  src="https://clics.dev/tracker.js"
></script>
```

## WordPress

1. On your WordPress dashboard, go to **Appearance → Theme Editor**
2. Open **Theme Header (header.php)**
3. Paste the tracker snippet before `</head>`
4. Click **Update File**

```html
<script
  defer
  data-project-id="YOUR_PROJECT_ID"
  src="https://clics.dev/tracker.js"
></script>
```

:::tip
Prefer a plugin-free approach? Use a header/footer injection plugin if your theme does not expose `header.php`.
:::

## Webflow

1. Open your project and click the **Webflow logo** → **Project Settings**
2. Go to **Custom Code**
3. Paste the tracker in **Head Code**
4. **Save Changes** and **Publish**

```html
<script
  defer
  data-project-id="YOUR_PROJECT_ID"
  src="https://clics.dev/tracker.js"
></script>
```

## Verify installation

After deploying, open your site and check **Realtime** in the dashboard. You should see your visit within a few seconds.

:::note
The track