> For the complete documentation index, see [llms.txt](https://docs.tracknow.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tracknow.io/integrations-and-tracking/wix-integration.md).

# WIX Integration

Tracknow integrates with WIX stores to automatically transmit data for completed purchases into your Tracknow dashboard. This enables accurate tracking and attribution of purchases made by customers referred by your affiliates.

***

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

Both integration methods require you to enable passing our unique affiliate identifier `click_id` to your landing page. For instructions, click [here](https://docs.tracknow.io/integrations/passing-click_id-to-a-landing-page).

***

### Integration

On your Wix dashboard navigate to **Settings** → **Custom Code** → Add Custom Code to the head section and choose to load code on each new page.

```
<script>
import wixLocation from 'wix-location';
import { local } from 'wix-storage';

$w.onReady(function () {
  const clickId = wixLocation.query.click_id;

  if (clickId) {
    local.setItem("click_id", String(clickId));
  }
});
</script>
```

<figure><img src="/files/LobcW9a0PiNPxrbhc29V" alt=""><figcaption></figcaption></figure>

Next, enable Velo Dev Mode for your website if it isn't on already.

<figure><img src="/files/MtGAtoqYupncerb3QSHz" alt=""><figcaption></figcaption></figure>

Click **My Store** on the left menu → **Store Pages** → **Thank You Page**

<figure><img src="/files/3rIht0FQ2bhRXhJCwrx3" alt=""><figcaption></figcaption></figure>

Add an HTML embedded code by clicking **Add** → **More** → **Embeds** on the left menu.

<figure><img src="/files/5qu0stxy8r2vXlagxgoQ" alt=""><figcaption></figcaption></figure>

Add the following code:

```
<script type="text/javascript">
  window.onmessage = (event) => {
    const data = event.data;
    if (!data || data.type !== "ORDER_AND_CLICK") return;

    const order = data.order;
    const clickId = data.click_id || "";

    // --- Calculate amount WITHOUT shipping ---
    const orderTotal = Number(order?.totals?.total ?? 0);

    const shippingAmount =
      Number(order?.totals?.shipping ?? 0) ||
      Number(order?.shippingInfo?.shippingFee ?? 0);

    const amountWithoutShipping = Math.max(
      0,
      (orderTotal - shippingAmount).toFixed(2)
    );

    // --- Extract coupon code (if any) ---
    let couponCode = "";
    if (order?.discount?.coupon?.code) {
      couponCode = order.discount.coupon.code;
    } else if (Array.isArray(order?.discounts) && order.discounts[0]?.coupon?.code) {
      couponCode = order.discounts[0].coupon.code;
    }

    var img = document.createElement("img");
    img.src =
      "https://{namespace}-tracking.tracknow.info/success.jpg" +
      "?campaign_id={campaign ID}" +
      "&amount=" + encodeURIComponent(amountWithoutShipping) +
      "&order_id=" + encodeURIComponent(order?.number ?? "") +
      "&click_id=" + encodeURIComponent(clickId) +
      "&coupon=" + encodeURIComponent(couponCode);

    img.height = "1";
    img.width = "1";
    img.style.display = "none";
    document.body.appendChild(img);
  };
</script>
```

{% hint style="info" %}
Replace the **{namespace}** placeholder with your actual Tracknow namespace before pasting this URL.\
Replace the **{campaign ID}** placeholder with your actual Tracknow campaign ID before pasting this URL.
{% endhint %}

<figure><img src="/files/ucoG2jBPMSCvhFcKsyZQ" alt=""><figcaption></figcaption></figure>

Add the following code to the **Thank You Page** code page and replace ‘thankYouPage1’ ID to the actual thank you page ID if it’s different and also replace embedded html id from “html3” to the ID Wix generated for that element.

```
import { local } from 'wix-storage';

$w.onReady(function () {
  const clickId = local.getItem("click_id") || "";

  $w('#thankYouPage1').getOrder()
    .then((order) => {
      $w('#html3').postMessage({
        type: "ORDER_AND_CLICK",
        order: order,
        click_id: clickId
      });
    })
    .catch(() => {});
});
```

<figure><img src="/files/8EazlZVLQkDpwxXvE0Hg" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tracknow.io/integrations-and-tracking/wix-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
