Saltar al contenido

Partner program

For shops in Fordeal's own affiliate program: the clicks we sent you, the orders they made, your commission and the monthly statements. Commission is a percentage of the order value without VAT and shipping and is approved once the return window has passed.

Loading…

How to add the tracking code

Two pieces of code. The first, on every page, remembers the Fordeal click for 30 days in your shop's own cookie. The second, on the thank-you page, reports the order number and its value to Fordeal. No third-party cookies and no customer data.

1. Code for every page

Shoptet admin: Vzhled a obsah → Editor → HTML kód → Záhlaví.

<script>
(function () {
  try {
    var m = /[?&]fdclid=([0-9a-f-]{36})/i.exec(location.search);
    if (!m) return;
    // First-party cookie of the shop for 30 days; localStorage as a fallback.
    document.cookie = "fdclid=" + m[1] + "; Max-Age=2592000; path=/; SameSite=Lax; Secure";
    try { localStorage.setItem("fdclid", JSON.stringify({ id: m[1], at: Date.now() })); } catch (e) {}
  } catch (e) {}
})();
</script>

2. Code for the thank-you page

Shoptet admin: Vzhled a obsah → Editor → HTML kód → Dokončená objednávka. It reads the order from Shoptet's data layer (orderNo, total, totalWithoutVat).

<script>
(function () {
  // true while testing: the order is stored as a test and is never billed.
  var FORDEAL_TEST = false;
  try {
    var click = null;
    var c = /(?:^|;\s*)fdclid=([0-9a-f-]{36})/i.exec(document.cookie);
    if (c) click = c[1];
    if (!click) {
      try {
        var saved = JSON.parse(localStorage.getItem("fdclid") || "null");
        if (saved && Date.now() - saved.at < 2592000000) click = saved.id;
      } catch (e) {}
    }
    if (!click) return; // the visitor did not come from Fordeal
    var order_number = null, total = null, total_without_vat = null, currency = null;
    var o = null;
    try { if (typeof getShoptetDataLayer === "function") o = getShoptetDataLayer("order"); } catch (e) {}
    if (!o && window.dataLayer) {
      for (var i = 0; i < dataLayer.length; i++) {
        if (dataLayer[i] && dataLayer[i].shoptet && dataLayer[i].shoptet.order) { o = dataLayer[i].shoptet.order; break; }
      }
    }
    if (o) {
      order_number = o.orderNo;
      total = typeof o.total === "number" ? o.total : null;
      if (typeof o.totalWithoutVat === "number") {
        total_without_vat = Math.round((o.totalWithoutVat - (typeof o.shippingWithoutVat === "number" ? o.shippingWithoutVat : 0)) * 100) / 100;
      }
      currency = o.currencyCode || null;
    }
    var body = new Blob([JSON.stringify({
      click_id: click,
      order_number: order_number == null ? null : String(order_number),
      total: total,
      total_without_vat: total_without_vat,
      currency: currency,
      platform: "shoptet",
      test: FORDEAL_TEST
    })], { type: "text/plain" });
    var url = "https://fordeal.ai/api/v1/deals/conversions";
    if (!(navigator.sendBeacon && navigator.sendBeacon(url, body))) {
      fetch(url, { method: "POST", mode: "no-cors", body: body, keepalive: true });
    }
    // Delete the click so a reload of this page does not report the order again.
    document.cookie = "fdclid=; Max-Age=0; path=/; SameSite=Lax; Secure";
    try { localStorage.removeItem("fdclid"); } catch (e) {}
  } catch (e) {}
})();
</script>

Testing: set FORDEAL_TEST = true in the thank-you code, open your shop through a Fordeal link and finish an order. It appears in the table above as „test“ and is never billed. Set it back to false when done.