# Install the pixel

The pixel is a small snippet you install on your site. It records visits and where each one came from, so LeadStalker can tie your leads and sales to the campaigns and ads that brought them.

## What it does

- Records the pages visited, including on single-page sites (React, Vue, Next.js…).
- Stores the source of each visit: UTMs, referring site and the click IDs from Google, Meta, TikTok and Microsoft Ads.
- Recognizes the same visitor when they come back, with an anonymous identifier stored on your own site.
- Loads asynchronously, without slowing your site down, and never reads what is typed in forms.

## Generate the snippet

1. In the app, open **Business settings → Pixel**.
2. Enter your site's URL and click **Generate pixel**.

Each site gets its own snippet: it only works on the domain you entered and its subdomains. Generating again for the same site always returns the same snippet.

The snippet looks like this:

```html
<!-- LeadStalker Pixel -->
<script>window.lsq=window.lsq||[];function ls(){lsq.push(arguments)}</script>
<script async src="https://dash.leadstalker.app/track.js" data-ls-pixel="YOUR_TOKEN"></script>
```

::: tip The snippet is public
It is visible in your site's HTML and gives no access to your account.
:::

## Where to paste it

Paste it before `</head>` on **every** page of your site — including landing pages, checkout and thank-you pages — and publish.

Rules for any site:

- There are two `<script>` tags: keep both, in that order. The first creates the `ls()` function, which your site can call before the pixel finishes loading.
- Don't change, minify or remove attributes: `data-ls-pixel` is required, and `async` must stay.
- Load the snippet only once per page.

### Single-page sites

In React, Vue, Next.js and similar, put the snippet in the root layout or template, never inside page components. The pixel detects route changes on its own.

### Next.js

Use two `<Script>` components from `next/script` with `strategy="afterInteractive"`, in the same order: the first with `id="leadstalker-queue"` and the first tag's code as content; the second with the same attributes as the second tag.

### WordPress

Use the `wp_head` hook or the header scripts field of your theme or page builder.

### Google Tag Manager

Create a **Custom HTML** tag with the snippet, firing on all pages.

## Content Security Policy

If your site uses a Content Security Policy, allow the script origin in `script-src` and the collection origin in `connect-src`. The app's **Pixel** tab shows both exact addresses in the AI installation prompt.

## Install with an AI assistant

Do you use an assistant that edits your site's code (ChatGPT, Claude, Cursor, Lovable…)? The **Pixel** tab has a **Copy prompt** button with the snippet and every rule above, already with your domain. Paste it into the assistant.

## Check it

Open your site in another tab and watch the visit show up in **Live**.

Next step: [identify signed-in users](/en/pixel/identificar).
