Adding a custom JavaScript callback to a booking engine embedded on your website enables you to track events.
Note: This requires some basic knowledge of JavaScript callbacks. Consult your web developer if you need any assistance.
Before You Start
- Add a custom script to your webpage.
Tracking Events in the Booking Engine
Adding a JavaScript Callback
- In Sirvoy, go to Settings -> Booking engines.
- Click the three dots adjacent to the booking engine you want.
- In the drop-down list, click “How to Install.”
- Click “Advanced.”
- In “JavaScript callback function”, fill in the name of the function to call.
- Copy the code from “Copy this code.”
- Add the code to your webpage to install the booking engine.
Your function is now called for each step the guest takes in the booking engine.
Events Fired in the Booking Engine Flow:
- page_code_required – Fires when the form to enter a coupon code is displayed (if that is required for your booking engine).
- page_search – Fires when the search form is displayed. Extra data: “user_data” (arrivalDate, departureDate, totalAdults, category)
- page_results – Fires when the search results page is displayed. Extra data: “user_data” (same as page_search)
- page_details – Fires when the guest details input form is displayed. 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 a booking is completed on the confirmation page. Extra data: “booking” (JSON representation of the booking)
Tip: After the last event in the booking engine flow has completed, all booking details will be available under the key “booking” in the JSON representation of the booking.
Note: The event “booking_completed” is guaranteed to fire only once per booking. Other events, such as “page_confirmation” and “page_pending” may fire multiple times if the guest is making optional payments. Every time the guest is redirected back from the payment provider, these events will fire again.
Note: When a custom image gallery is used on the search results page, the events “gallery_init” and “gallery_open” will also fire.
Tracking Events in the Review Booking Form
Adding a JavaScript Callback
- In Sirvoy, go to Settings -> Guest portal -> Install, and click “Advanced.”
- Fill in the name of the function you want to call in the field “JavaScript callback function.”
- Copy the code from “Copy this code.”
- Add the code to your webpage to install the review booking form.
Your function is now called for each step the guest takes in the review booking form.
Events Fired in the Review Booking Form Flow:
- page_review_search – Fires when the review search form is displayed.
- page_review_booking – Fires when the review booking page is displayed. Extra data: “booking” (JSON representation of the booking)
- page_review_pending – Fires after an optional payment is made through the review form. After this event the page displays the review booking form again and the “page_review_booking” event is fired again. Extra data: “booking” (JSON representation of the booking)
Tip: All details of an existing booking are available under the key “booking” in the JSON representation of the booking.
Before You Go
Explore the available events and their associated data with the code below by printing out all the events in the web developer console:
<script>
function customEventHandler(data) {
console.log("Got Sirvoy custom JS event: " + data.event);
console.dir(data);
}
</script>