# Passing click\_id to a Landing Page

Each time someone clicks on an affiliate's tracking URL, that click is logged by our system. Click records hold information like:

1. The affiliate whose link was clicked
2. The campaign that the link is associated with
3. Basic metadata about the client (IP address and user agent)

**Every click record has a click ID**. This parameter is essential for ensuring reliable tracking.

When a client clicks an affiliate link, they are redirected to your chosen landing page. You can enable passing the client’s click\_id in the URL so that when they complete a purchase or another tracked action, this click\_id is sent along with the purchase details to your Tracknow dashboard. This allows the system to accurately attribute the purchase to the correct affiliate.

Think of it like a client visiting a store after being recommended by an affiliate. When they walk in, they are wearing a sticker with the affiliate’s name. When the client makes a purchase, the seller checks the sticker to see which affiliate referred them and credits that affiliate accordingly.

***

### Set Up

Navigate to **Campaigns** → Locate the relevant campaign → click the three-dot icon under the **Actions** column → **Edit** → **Tracking** tab → Add the click\_id parameter key and macro to the **Default Landing Page** URL and to the **Deep Link Passed Parameters** field

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

Now, each time a client clicks an affiliate link, he will be directed to your landing page with his click\_id in the URL

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

***

### Storing the `click_id` in a Cookie

After the `click_id` is passed to your website, you must store it in a browser cookie to ensure it persists while the user navigates across different pages. This prevents the value from being lost during the session and ensures it remains available when the client completes the tracked event.

You can use the following script template to store the `click_id` in a cookie:

```javascript
<script>
// Get a query parameter by name from the URL
function getQueryParam(name) {
  const urlParams = new URLSearchParams(window.location.search);
  return urlParams.get(name);
}

// Set a cookie for the root domain, available across subdomains
function setCookie(name, value, days) {
  const maxAge = days * 24 * 60 * 60; // days to seconds
  const domain = "." + window.location.hostname.split('.').slice(-2).join('.'); // example.com

  document.cookie = `${name}=${encodeURIComponent(value)}; path=/; domain=${domain}; max-age=${maxAge}; secure;`;
}

// Main: look for click_id and store it
(function () {
  const clickId = getQueryParam("click_id");
  if (clickId) {
    setCookie("click_id", clickId, 365); // store for 1 year
  }
})();
</script>
```

{% hint style="info" %}
Please ensure this script is implemented in the \<head> section of your website so that it is loaded on all pages. This ensures the script remains effective even if the landing page changes, and no code adjustments will be required.
{% endhint %}


---

# Agent Instructions: 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:

```
GET https://docs.tracknow.io/integrations-and-tracking/passing-click_id-to-a-landing-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
