By specifying “data-callback” when including the Sirvoy widget, you will be able to catch events and run your own custom scripts (see example below). In most scenarios, you will only be interested in the ‘booking_completed’ event.

You can also control when to trigger the built-in Google Analytics or Facebook Pixel tracking by returning “false” from your function to skip it for this event. This can be useful in combination with a cookie consent banner that has not yet been accepted or if you only want to trigger specific events. The default is to trigger the built-in tracking you have set up, so if any other value than “false” (or nothing at all) is returned, the tracking will trigger.

For booking flow these events will be fired:

  • page_code_required – fires on the form to enter the coupon code if that is required for your booking engine.
  • page_search – fires when displaying the search form. Extra data: “user_data” (arrivalDate, departureDate, totalAdults, category)
  • page_results – fires when displaying the search results. Extra data: “user_data” (same as page_search)
  • page_details – fires when displaying the guest details input form. Extra data: “user_data” (same as page_search)
  • page_pending – fires before the confirmation step, after returning from a payment provider or if you don’t use a payment provider after the page_details event. Extra data: “booking” (JSON representation of the booking)
  • page_confirmation fires on the confirmation step, after returning from a payment provider or if you don’t use a payment provider after the page_details event. Extra data: “booking” (JSON representation of the booking)
  • booking_completed – fires when booking is final and completed on confirmation page. This event is guaranteed to fire only once per booking, while for example you could have multiple “page_confirmation” or “page_pending” if the guest is making optional payments – once he is redirected back from the payment provider these events will fire again. Extra data: “booking” (JSON representation of the booking)

For review flow these events will be fired:

  • page_review_search – fires when displaying the review search form.
  • page_review_booking – fires when displaying the review booking page. Extra data: “booking” (JSON representation of the booking)
  • page_review_pending – fires after an optional payment made via review form, and after this event the page will display the review booking form again and the “page_review_booking” event fired again. Extra data: “booking” (JSON representation of the booking)

Add a custom script to your page and generate a new code to install the booking engine by going to Settings -> Booking engine -> How to install.

On the How to install page, click “Advanced” and in the input field “Javascript callback function” fill in “customEventHandler” for the example below, or the name of the function you want to be called. Copy the code from the “Copy this code” field to your website. Now your function will be called for each step the guest makes during the booking.

When a booking has been made or previously exists (last step in booking process, or review flow), there is extra data under the key “booking” available in the event with all the details about the booking. See this article for more information about the format used for the “booking” key.

Below is an example that can be used to explore the different available events and associated data, but this particular example does nothing other than to print out all the events in the web developer console. To use it for a real integration, some Javascript knowledge is needed.


      <script>
         function customEventHandler(data) {
            console.log("Got Sirvoy custom JS event: " + data.event);
            console.dir(data);
        }
      </script>
   
Note: The events gallery_init and gallery_open will also be fired when the image gallery is used on results page, see this article for details.