# Overview

This tracking code is responsible for **capturing the conversion / order** and must be output on the **order confirmation page**.

---

## JavaScript Code

```html
<script>
(function() { 

    var campaign_id = 'CAMPAIGN_ID';
    var trigger_id = 'TRIGGER_ID';
    var token = 'ORDERTOKEN'; 
    var turnover = 'TURNOVER';
    var descr = 'DESCRIPTION';
    var currency = 'EUR';
    var storageKey = 'emid';
    var trackingDomain = 'SUB-DOMAIN';

    /* Please insert the EMID here that was previously passed to the landing page via the GET parameter */
    /* If it is not possible to store the EMID, please leave this line as it is */
    var emid = null;

    var attribution = '1';

    var trackingUrl = 'https://'+trackingDomain+'/trck/etrack/?campaign_id='+campaign_id+'&trigger_id='+trigger_id+'&token='+token+'&descr='+descr+'&currency='+currency+'&turnover='+turnover+'&attribution='+attribution+'&t=js';

    emid = emid || window.localStorage[storageKey];

    if(emid) {
        trackingUrl += '&emid='+emid;
    }

    var req = new XMLHttpRequest;
    req.withCredentials = true;
    req.open("GET", trackingUrl);
    req.send();
    req.onreadystatechange = function () { 
        (req.readyState === 4) ? eval(req.response) : null 
    };

})();
</script>
```

---

## Important Note Regarding the `emid`

- The **customer is responsible** for storing the `emid` (e.g., via `localStorage` or another mechanism).  
- The `emid` is passed to the landing page as a **GET parameter** (e.g., `?emid=12345`).  
- The tracking code accesses the stored `emid` and uses it on the order confirmation page.  
- If the `emid` **was not saved**, it cannot be used in tracking → the transaction will not be captured correctly.  

---

## Variable Description

The variables are initialized at the beginning of the code.  
The placeholder values must be replaced with the corresponding values.

| Variable | Description |
|---|---|
| `CAMPAIGN_ID` | Campaign ID |
| `TRIGGER_ID` | Trigger ID |
| `TOKEN` | Order number / Order ID |
| `TURNOVER` | Net order value. This may determine the commission for the publisher. |
| `DESCR` | Description of the order |
| `CURRENCY` | Current currency (Default: Affiliate program setting). Example: CHF for Swiss shops that settle in € |
| `STORAGEKEY` | Key in `localStorage` where the `emid` is saved |
| `TRACKINGDOMAIN` | Domain of the partner platform |
| `ATTRIBUTION` | Attribution in decimal format using a dot as a separator (e.g., `0.50` for 50%) |
| `EMID` | Value of the `emid` parameter passed to the landing page via the click link |