Przejdź do treści

Program partnerski

Dla sklepów we własnym programie partnerskim Fordeal: kliknięcia, które do Was wysłaliśmy, zamówienia z nich, Wasza prowizja i miesięczne rozliczenia. Prowizja to procent wartości zamówienia bez VAT i dostawy, zatwierdzany po upływie terminu na zwrot.

Ładowanie…

Jak wstawić kod śledzący

Dwa fragmenty kodu. Pierwszy, na każdej stronie, zapamiętuje kliknięcie z Fordeal na 30 dni we własnym pliku cookie sklepu. Drugi, na stronie podziękowania, przesyła do Fordeal numer zamówienia i jego wartość. Bez plików cookie stron trzecich i bez danych klienta.

1. Kod na każdą stronę

Panel Shoptet: Vzhled a obsah → Editor → HTML kód → Záhlaví (nagłówek).

<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. Kod na stronę podziękowania

Panel Shoptet: Vzhled a obsah → Editor → HTML kód → Dokončená objednávka (zakończone zamówienie). Odczytuje zamówienie z warstwy danych Shoptet (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>

Test: w kodzie strony podziękowania ustaw FORDEAL_TEST = true, otwórz sklep przez link z Fordeal i złóż zamówienie. Pojawi się w tabeli powyżej jako „test“ i nigdy nie zostanie rozliczone. Po teście przywróć false.