# DanDomain Classic

> Tracking on the older DanDomain engine – the tracking code in the site's code field and the sale code on Bestil step 4 (order step 4).

DanDomain Classic is the older DanDomain engine. You can recognise it by addresses containing `/shop/frontpage.html` and by `[[variables]]` in the templates. It has two code fields in two different parts of the admin: one that is written out on every page, and one that is only shown after a completed purchase.

DanDomain's admin is in Danish, so the menu names below are given in Danish (as you will see them), with an English gloss in brackets.

> [!NOTE]
> If the shop runs the new Dandomain Webshop (the same engine as Smartweb and HostedShop), use [Smartweb and HostedShop](https://www.affilyflow.com/en/docs/store/smartweb) instead.

## Before you start

- Access to the shop admin – both **Opsætning** (Settings) and **Design → Tekster/knapper** (Design → Texts/buttons).
- The snippets from **Program → Setup** in Affilyflow, where your store ID is already filled in. In this guide, `DIN_BUTIK` stands for your store ID.
- Setup usually recognises the platform on its own. If it is not selected, choose **DanDomain Classic**.

## 1. The tracking code in the site's code field

Go to **Opsætning → Site → rediger jeres site → Kodefelt** (Settings → Site → edit your site → Code field) and paste the code in. The field is written out at the top of every page. (This is DanDomain's own **Opsætning** menu – not Setup in Affilyflow.)

```html title="Tracking code – goes on every page"
<script src="https://app.affilyflow.com/t/DIN_BUTIK.js" async></script>
```

- If the menu item is called **Indstillinger** rather than **Opsætning**, it is the same place – DanDomain uses both names (both mean "settings").
- If you have several sites in the same shop, the code has to go onto each site.

## 2. The sale code on Bestil step 4

Go to **Design → Tekster/knapper → Bestil step 4 → Kodefelt** (Design → Texts/buttons → Order step 4 → Code field) and paste the sale code in. That page is only shown after a completed purchase. If the shop has several languages, check whether **Tekster/knapper** has a language selector – the code has to go into each language, or sales in the other languages won't be recorded.

```html title="Sale code – only on Bestil step 4 (order step 4)"
<script>
  (function () {
    // Laeser beloebet, uanset om det kommer med valuta eller tusindtalsseparator.
    function tal(v) {
      // '499,-' og '1.249,-' er almindelige i Danmark: et afsluttende ',-' fjernes,
      // og et minus taeller kun forrest.
      var t = String(v).replace(/[^0-9.,-]/g, '').replace(/[.,]?-+$/, '').replace(/(?!^)-/g, '').replace(/^[.,]+|[.,]+$/g, '');
      var k = t.lastIndexOf(','), p = t.lastIndexOf('.');
      if (k > -1 && p > -1) t = k > p ? t.split('.').join('').replace(',', '.') : t.split(',').join('');
      else {
        var sep = k > -1 ? ',' : p > -1 ? '.' : '';
        if (sep && (t.split(sep).length > 2 || t.length - t.lastIndexOf(sep) === 4)) t = t.split(sep).join('');
        else if (sep === ',') t = t.replace(',', '.');
      }
      return Number(t) || 0;
    }
    var id = '[[OrderID]]';
    if (id.indexOf('[[') === 0) id = '';
    var raw = '[[SubTotalExclShippingAndPaymentFeesExclVAT]]';
    // Staar variablen her endnu, ligger koden et sted uden ordre: send intet (audit 19. okt, I1).
    if (raw.indexOf('[[') === 0) {
      console.error('Affilyflow: salgskoden skal i feltet paa Bestil step 4 (ordrebekraeftelsen).');
      return;
    }
    var total = tal(raw);
    if (!(total > 0)) return;
    // DanDomain har ingen valutakode-variabel; beloebet staar med valuta, fx "EUR 49,95".
    // "kr." kan ikke skelnes, saa uden kode bruges butikkens valuta (audit 19. okt, I3).
    var cur = (raw.match(/[A-Z]{3}/) || [''])[0];
    var tries = 0;
    (function send() {
      if (!window.affilyflow) { if (tries++ < 50) setTimeout(send, 200); else console.error('Affilyflow: sporingskoden (track.js) mangler paa siden - salget er ikke registreret.'); return; }
      affilyflow.conversion({ order: id, total: total, currency: cur });
    })();
  })();
</script>
```

The shop fills in the order number and amount itself wherever there is a `[[variable]]`. The amount is the basket total excluding VAT, shipping and fees – exactly what commission should be calculated on.

> [!WARNING]
> There is also **Design → Skins → Bestil step 4**. That is the design template and the wrong place. The sale code goes in **Tekster/knapper** (Texts/buttons).

**Currency:** DanDomain has no variable with the currency code. If the amount carries a code such as `EUR 49,95`, that code is used; if it only says "kr.", the sale is recorded in DKK. If you sell in currencies other than Danish kroner (SEK or NOK, for example), write to us before you go live.

## 3. Test

Go to the **Test tracking** step in Setup in Affilyflow, press **Open test link** and place a test order in the tab that opens. Stay in Setup – the live test shows the test click and the purchase with order number and amount, and asks whether the amount is right. A test purchase gives no commission and no fee. A purchase without a click from a link is not counted.

> [!TIP]
> If you have a Google Analytics ID in the shop's tracking field, leave it there – our code is not Google Analytics and is happy to sit alongside it. DanDomain's own warning against double implementation is about two GA codes.

## Common problems

| What you see | Cause |
|---|---|
| Setup can't find the tracking code | If the shop has several sites, the code must be in the code field of the site the front page belongs to. |
| The console says "salgskoden skal i feltet paa Bestil step 4" | The sale code is in the site's code field. Move it to Tekster/knapper → Bestil step 4. |
| The sale arrives without an order number | The `[[OrderID]]` variable wasn't filled in. Without a number, a reloaded receipt can count as a new sale. |

The console messages are in Danish – they are written by the snippets above, which are the same for every store. More in [Testing and troubleshooting](https://www.affilyflow.com/en/docs/store/testing-and-troubleshooting).

## Refunds

The platform doesn't report refunds to us. You need to reject a refunded purchase yourself within the approval period – see [Approval and refunds](https://www.affilyflow.com/en/docs/store/approval-and-refunds).

Source: https://www.affilyflow.com/en/docs/store/dandomain-classic
