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

# Install with a script

> Load the Lemrock Pixel and report events from your site's code.

Install the Lemrock Pixel in your site's code. You need your **pixel ID**, from your Lemrock contact. To check the install, see [Check your setup](/en/conversion-tracking/reference#check-your-setup).

## 1. Load the pixel

Paste this into the `<head>` of your page template, so it runs on every page. Replace `lr_px_...` with your pixel ID.

```html theme={null}
<script>
  (function (w, d, s, u) {
    if (w.lemrock) return;
    var q = function () {
      q.q.push(arguments);
    };
    q.q = [];
    w.lemrock = q;
    var js = d.createElement(s);
    js.async = true;
    js.src = u;
    d.head.appendChild(js);
  })(
    window,
    document,
    "script",
    "https://cdn.lemrock.com/scripts/pixel/latest/pixel.js",
  );

  lemrock("init", { pixelId: "lr_px_..." });
</script>
```

The script loads in the background and doesn't slow your page.

## 2. Report events

Call `measure` when the event happens, for example on your order confirmation page. The snippet from step 1 must be on that page too.

```js theme={null}
lemrock(
  "measure",
  "order_created",
  {
    type: "contents",
    amount: 5198,
    currency: "EUR",
    contents: [
      {
        id: "sku_123",
        name: "Blue shirt",
        quantity: 2,
        amount: 2599,
        currency: "EUR",
      },
    ],
  },
  { event_id: "12345" },
);
```

The other three events are the same call with a different event name. Amounts are always in cents here: `2599` for €25.99.

## 3. Add user data (recommended)

Add a hashed `user` to `init`. See [Hash email and phone](/en/conversion-tracking/reference#hash-email-and-phone).

```js theme={null}
lemrock("init", {
  pixelId: "lr_px_...",
  user: {
    email_sha256:
      "86e0b9e56c17cc4d12387e1949b85053fbe73bc3ce5a1188713a9d300cc6133d",
    phone_number_sha256:
      "8a3e7886c9335e82e02299fa3e87b46e2de3b0c63d56003e30a5029394a47661",
  },
});
```

If you only learn who the visitor is later, for example after login, call `init` again with just the `user`.

Only send it for visitors whose consent covers sharing their email or phone with Lemrock for ad measurement.

* **User data lasts one page.** Send it on every page where you know the visitor and report an event, before the `measure` call.
* **A new** `user` **replaces the previous one.** Send both identifiers together if you have both.

## 4. Set up consent

The pixel assumes consent until told otherwise. If your site asks visitors for consent, pass the answer:

```js theme={null}
lemrock("consent", false); // refused: the pixel stops and deletes its click cookie
lemrock("consent", true); // accepted
```

* **Pass** `true` **or** `false`**, not a string.** Anything other than `true` counts as a refusal, including `"true"`.
* **The refusal is remembered**, so you don't need to repeat the call on every page.
* **If your consent banner blocks scripts until the visitor answers, block the Lemrock snippet too.**


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