How to track patient's progress through the online booking widget

Modified on Fri, 18 Jul at 9:53 PM

As a patient navigates the booking widget, a number of events are triggered, these can be listened to through the use of JavaScript, allowing you to then take action, such as sending to analytics or redirecting to a specific page.



Events

These are the events that are emitted from the widget, along with the values:


appointment-type-selected


This event is emitted whenever the patient selects an appointment type

The event detail is an object with the following fields:


FieldTypeDescription
descriptionstring or undefinedThe description of the appointment type that is entered into HearLink
durationnumberThe duration of the appointment in minutes
labelstringThe appointment type name
pricestring or undefinedThe price of the appointment type that is entered into HearLink
valuestring or undefinedThe unique ID for this appointment type



clinic-selected


This event is emitted whenever the patient selects a clinic

The event detail is an object with the following fields:


FieldTypeDescription
addressstringThe address entered for this clinic
enabledDaysarrayA list of day indexes that are enabled for selection
labelstringThe appointment type name
valuestring or undefinedThe unique ID for this clinic



month-changed


This event is emitted whenever the patient changes the month on the date selection page

The event detail is an object with the following fields:


FieldTypeDescription
monthstringMonth in format MM (01 - 12)
dateDayjsA Dayjs object representing the start of the month



date-selected


This event is emitted whenever the patient selects a date for their appointment on the date selection page

The event detail is an object with the following fields:


FieldTypeDescription
dateStringstringThe selected date for the appointment, format YYYY-MM-DD
dateDayjsA Dayjs object representing the selected date



slot-selected


This event is emitted whenever the patient changes the month on the date selection page

The event detail is an object with the following fields:


FieldTypeDescription
slotstringThe selected slot for the appointment, format HH:mm



booking-completed


This event is emitted once the booking has been successfully submitted

The event detail is an object with the following fields:


FieldType
appointmentTypeObject
  • duration - number
  • label - string
  • value - string
clinicObject
  • address - string
  • label - string
  • value - string
dateObject
  • dateString - string
  • date - Dayjs
slotObject
  • slot - string
fullNamestring
phoneNumberstring
emailAddressstring or undefined
dobstring or undefined
referralstring or undefined



Example integration

This is an example of how you could listen to an event from the booking widget:

<html>
  <head>
    <script src="https://storage.googleapis.com/cdn.hearlink.co.uk/index-CfY56Ylb.js"></script>
    <script defer>
      document.addEventListener("DOMContentLoaded", () => {
        customElements.whenDefined("booking-widget").then(() => {
          const widget = document.querySelector("booking-widget");
          widget.addEventListener("appointment-type-selected", (e) => {
            const detail = e.detail;
            // Handle the appointment type selection
          });
        });
      });
    </script>
  </head>
  <booking-widget
    organisationId="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
    primaryColour="#000000"
  ></booking-widget>
</html>


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article