Skip to content

Advanced Usage

Analytics & GTM

The widget fires standard DOM CustomEvents with bubbles: true and composed: true. They cross the shadow DOM boundary and are visible at window level — no special configuration needed.

Event reference

EventFires whenDetail payload
booksea:widget-loadedWidget data has loaded{ companySlug }
booksea:availability-confirmedDate and service are confirmed as available{ service, date, pax }
booksea:checkout-startedPayment intent created (user clicked Pay Now){ pricingUuid, total, currency }
booksea:payment-successStripe confirms the payment{ bookingReference, total, currency }
booksea:payment-failurePayment failed or was cancelled{ errorCode } — see error codes

Listening to events

Subscribe to any event in plain JavaScript:

js
window.addEventListener('booksea:payment-success', function (e) {
  console.log('Booking confirmed:', e.detail.bookingReference);
});

Error codes

Possible values for errorCode in booksea:payment-failure:

CodeMeaning
payment_cancelledCustomer closed the payment modal
payment_declinedCard was declined by the issuer
payment_network_errorNetwork or connectivity failure during payment
payment_timeoutPayment request timed out
payment_failedAny other failure

GTM bridge example

How you bridge events into dataLayer depends on your GTM setup. Here is one way to do it:

html
<script>
(function () {
  window.dataLayer = window.dataLayer || [];

  window.addEventListener('booksea:payment-success', function (e) {
    var detail = e.detail || {};
    window.dataLayer.push({
      event: 'payment_success',
      booksea_total: detail.total || '',
      booksea_currency: detail.currency || 'EUR',
      booksea_reference: detail.bookingReference || '',
    });
  });

  window.addEventListener('booksea:checkout-started', function (e) {
    var detail = e.detail || {};
    window.dataLayer.push({
      event: 'pay_now_click',
      booksea_total: detail.total || '',
      booksea_currency: detail.currency || 'EUR',
    });
  });
})();
</script>