WebePartners
v1.2

Wprowadzenie #

Snippet webe.js wczytywany jest na każdej stronie sklepu. Automatycznie identyfikuje użytkownika który trafił przez link afiliacyjny, a po dokonaniu konwersji wysyła request do jednego endpointu:

GET https://webeh1.com/o/neworder.js

Ten sam endpoint obsługuje oba modele rozliczenia — typ konwersji określa parametr type:

CPS  type=cps — zamówienie (wartość domyślna, można pominąć)

CPL  type=cpl — lead / formularz / rejestracja

Do działania potrzebujesz ID serwisu (MID) — otrzymasz go od opiekuna WebePartners.


1 Instalacja snippetu #

Wklej poniższy kod w sekcji <head> na każdej stronie sklepu. Zastąp TWOJE_MID swoim ID serwisu.

html
<script
  src="https://webeh1.com/webe.js"
  data-webe-mid="TWOJE_MID"
  async
></script>

Atrybut data-webe-mid identyfikuje Twój serwis. Atrybut async gwarantuje nieblokujące ładowanie.


Endpoint API #

Snippet wywołuje jeden endpoint dla obu typów konwersji:

GET https://webeh1.com/o/neworder.js

Parametry query string

ParametrTypWymaganyDomyślnieOpis
mid int TAK ID serwisu (MID)
refer string TAK Numer / ID zamówienia lub leadu
type string nie cps Model konwersji: cps lub cpl
sum decimal nie Wartość brutto konwersji bez kosztów wysyłki (wymagane dla CPS, opcjonalne dla CPL)
dc string nie Użyty kod rabatowy
visitoruid string nie UID odwiedzającego z ciasteczka webe_vuid — snippet uzupełnia automatycznie
Parametr visitoruid jest uzupełniany przez snippet automatycznie z ciasteczka webe_vuid. Nie musisz go przekazywać ręcznie w kodzie strony.

2 Event zamówienia CPS #

Na stronie podziękowania za zamówienie wywołaj window.__webe.order(). Snippet musi być już załadowany — stąd używamy window.load.

html
<script>
window.addEventListener('load', async function () {
  await window.__webe.order({
    type:  'cps',      // model konwersji — wymagany
    refer: 'TX-9912',  // numer zamówienia — wymagany
    sum:   599.00,     // wartość brutto bez wysyłki — wymagany
    dc:    'KOD20',   // kod rabatowy — opcjonalny
  });
});
</script>

Parametry

ParametrTypWymaganyOpis
typestringTAKModel konwersji — wartość stała: cps
referstringTAKNumer lub ID zamówienia ze sklepu
sumnumberTAKWartość brutto zamówienia bez kosztów wysyłki
dcstringnieUżyty kod rabatowy

Snippet automatycznie dodaje mid oraz visitoruid przed wysłaniem requestu.

Wartości refer i sum muszą być dynamicznie podstawiane przez backend sklepu — nie wpisuj ich na stałe w szablonie.

2 Event leadu CPL #

Jeśli serwis rozlicza się w modelu CPL (np. wypełnienie formularza, rejestracja), wywołaj window.__webe.lead() na stronie potwierdzenia. Snippet wyśle request z type=cpl.

html
<script>
window.addEventListener('load', async function () {
  await window.__webe.lead({
    type:  'cpl',        // model konwersji — wymagany
    refer: 'LEAD-4421',  // ID leadu / zgłoszenia — wymagany
    sum:   49.00,        // wartość leadu — opcjonalny
    dc:    'KOD20',     // kod rabatowy / kampania — opcjonalny
  });
});
</script>

Parametry

ParametrTypWymaganyOpis
typestringTAKModel konwersji — wartość stała: cpl
referstringTAKUnikalny identyfikator leadu / zgłoszenia
sumnumbernieWartość leadu, jeśli jest znana
dcstringnieKod kampanii lub rabatowy

Snippet automatycznie dodaje mid oraz visitoruid przed wysłaniem requestu.


WooCommerce #

Dodaj poniższy kod do functions.php aktywnego motywu lub wtyczki.

CPS — zamówienie

functions.php
php
add_action('woocommerce_thankyou', function ($order_id) {
  $order = wc_get_order($order_id);
  ?>
  <script>
  window.addEventListener('load', async function () {
    await window.__webe.order({
      type:  'cps',
      refer: '<?= esc_js($order->get_order_number()) ?>',
      sum:   <?= (float) $order->get_total() ?>,
      dc:    '<?= esc_js(implode(',', $order->get_coupon_codes())) ?>',
    });
  });
  </script>
  <?php
});

CPL — lead / rejestracja

functions.php
php
// Przykład: po pomyślnej rejestracji użytkownika
add_action('user_register', function ($user_id) {
  ?>
  <script>
  window.addEventListener('load', async function () {
    await window.__webe.lead({
      type:  'cpl',
      refer: '<?= esc_js($user_id) ?>',
    });
  });
  </script>
  <?php
});

PrestaShop #

Wklej snippet w szablonie strony podziękowania order-confirmation.tpl.

CPS — zamówienie

order-confirmation.tpl
smarty
<script>
window.addEventListener('load', async function () {
  await window.__webe.order({
    type:  'cps',
    refer: '{$order.reference}',
    sum:   {$order.total_paid},
    dc:    '{$order.discount_name|default:""}',
  });
});
</script>

CPL — lead / formularz

authentication.tpl
smarty
<script>
window.addEventListener('load', async function () {
  await window.__webe.lead({
    type:  'cpl',
    refer: '{$customer.id}',
    dc:    '{$campaign_code|default:""}',
  });
});
</script>

Shoper / inne platformy #

Wklej snippet JS w sekcji „Kod na stronie podziękowania" w ustawieniach sklepu, podstawiając odpowiednie zmienne szablonu.

Parametr JSShoperIdoSell
refer{order.id}{order_id}
sum{order.total}{order_total}
dc{order.discount_code}{discount_code}

Dla modelu CPL wywołaj window.__webe.lead() zamiast window.__webe.order() i zawsze przekazuj type: 'cpl'. Parametr sum jest opcjonalny — podaj go jeśli wartość leadu jest znana. Dla innych platform skonsultuj dokumentację — szukaj zmiennych odpowiadających numerowi zamówienia i wartości koszyka.


Testowanie #

Po wdrożeniu złóż testowe zamówienie / wypełnij formularz i otwórz DevTools → Network. Na stronie podziękowania powinien pojawić się request do:

CPS

https://webeh1.com/o/neworder.js?mid=TWOJE_MID&refer=NR_ZAMOWIENIA&sum=WARTOSC&type=cps

CPL

https://webeh1.com/o/neworder.js?mid=TWOJE_MID&refer=ID_LEADU&type=cpl

Status 200 = konwersja zarejestrowana poprawnie

Jeśli request nie pojawia się — upewnij się że snippet jest wczytany w sekcji <head> i że TWOJE_MID zostało zastąpione właściwym ID serwisu.

Introduction #

The webe.js snippet is loaded on every page of your store. It automatically identifies users who arrived via an affiliate link and, after a conversion, sends a request to a single endpoint:

GET https://webeh1.com/o/neworder.js

The same endpoint handles both commission models — the conversion type is set via the type parameter:

CPS  type=cps — order (default value, can be omitted)

CPL  type=cpl — lead / form submission / registration

You will need a Service ID (MID) — your WebePartners account manager will provide it.


1 Snippet installation #

Paste the code below into the <head> section of every page of your store. Replace YOUR_MID with your Service ID.

html
<script
  src="https://webeh1.com/webe.js"
  data-webe-mid="YOUR_MID"
  async
></script>

The data-webe-mid attribute identifies your service. The async attribute ensures the snippet loads without blocking page rendering.


API endpoint #

The snippet calls a single endpoint for both conversion types:

GET https://webeh1.com/o/neworder.js

Query string parameters

ParameterTypeRequiredDefaultDescription
mid int YES Service ID (MID)
refer string YES Order number / ID or lead ID
type string no cps Conversion model: cps or cpl
sum decimal no Gross conversion value excl. shipping (required for CPS, optional for CPL)
dc string no Discount code used by the customer
visitoruid string no Visitor UID from the webe_vuid cookie — appended automatically by the snippet
The visitoruid parameter is appended automatically by the snippet from the webe_vuid cookie. You do not need to pass it manually in your page code.

2 Order event CPS #

On the order thank-you page, call window.__webe.order(). The snippet must already be loaded — which is why we use the window.load event.

html
<script>
window.addEventListener('load', async function () {
  await window.__webe.order({
    type:  'cps',      // conversion model — required
    refer: 'TX-9912',  // order number — required
    sum:   599.00,     // gross value excl. shipping — required
    dc:    'CODE20',  // discount code — optional
  });
});
</script>

Parameters

ParameterTypeRequiredDescription
typestringYESConversion model — fixed value: cps
referstringYESOrder number or ID from your store
sumnumberYESGross order value excluding shipping costs
dcstringnoDiscount code used by the customer

The snippet automatically appends mid and visitoruid before sending the request.

The refer and sum values must be injected dynamically by your store's backend — never hardcode them in the template.

2 Lead event CPL #

If your service uses the CPL model (e.g. form submission, sign-up, registration), call window.__webe.lead() on the confirmation page. The snippet will send the request with type=cpl.

html
<script>
window.addEventListener('load', async function () {
  await window.__webe.lead({
    type:  'cpl',        // conversion model — required
    refer: 'LEAD-4421',  // lead / submission ID — required
    sum:   49.00,        // lead value, if known — optional
    dc:    'CODE20',    // campaign or discount code — optional
  });
});
</script>

Parameters

ParameterTypeRequiredDescription
typestringYESConversion model — fixed value: cpl
referstringYESUnique identifier of the lead or submission
sumnumbernoLead value, if known
dcstringnoCampaign or discount code

The snippet automatically appends mid and visitoruid before sending the request.


WooCommerce #

Add the code below to the functions.php file of your active theme or plugin.

CPS — order

functions.php
php
add_action('woocommerce_thankyou', function ($order_id) {
  $order = wc_get_order($order_id);
  ?>
  <script>
  window.addEventListener('load', async function () {
    await window.__webe.order({
      type:  'cps',
      refer: '<?= esc_js($order->get_order_number()) ?>',
      sum:   <?= (float) $order->get_total() ?>,
      dc:    '<?= esc_js(implode(',', $order->get_coupon_codes())) ?>',
    });
  });
  </script>
  <?php
});

CPL — lead / registration

functions.php
php
// Example: fire after successful user registration
add_action('user_register', function ($user_id) {
  ?>
  <script>
  window.addEventListener('load', async function () {
    await window.__webe.lead({
      type:  'cpl',
      refer: '<?= esc_js($user_id) ?>',
    });
  });
  </script>
  <?php
});

PrestaShop #

Insert the snippet in the order confirmation template order-confirmation.tpl.

CPS — order

order-confirmation.tpl
smarty
<script>
window.addEventListener('load', async function () {
  await window.__webe.order({
    type:  'cps',
    refer: '{$order.reference}',
    sum:   {$order.total_paid},
    dc:    '{$order.discount_name|default:""}',
  });
});
</script>

CPL — lead / form

authentication.tpl
smarty
<script>
window.addEventListener('load', async function () {
  await window.__webe.lead({
    type:  'cpl',
    refer: '{$customer.id}',
    dc:    '{$campaign_code|default:""}',
  });
});
</script>

Shoper / other platforms #

Paste the JS snippet in the "Thank-you page code" section of your store settings, substituting the appropriate template variables.

JS parameterShoperIdoSell
refer{order.id}{order_id}
sum{order.total}{order_total}
dc{order.discount_code}{discount_code}

For the CPL model, call window.__webe.lead() instead of window.__webe.order() and always pass type: 'cpl'. The sum parameter is optional — include it if the lead value is known. For other platforms, consult their documentation and look for variables matching the order number and cart value.


Testing #

After deployment, place a test order or submit a test form, then open DevTools → Network. The following request should appear on the confirmation page:

CPS

https://webeh1.com/o/neworder.js?mid=YOUR_MID&refer=ORDER_NUMBER&sum=VALUE&type=cps

CPL

https://webeh1.com/o/neworder.js?mid=YOUR_MID&refer=LEAD_ID&type=cpl

Status 200 = conversion recorded successfully

If the request does not appear, verify that the snippet is loaded in the <head> section and that YOUR_MID has been replaced with the correct Service ID.