Can I Add a Custom Script for Conversion Tracking?

searching ...

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.

The following events are currently available:

page_search – fires when displaying the search form.

Data: user_data (arrivalDate, departureDate, totalAdults, category)

page_results – fires when displaying the search results.

Data: user_data (same as page_search)

page_details – fires when displaying the guest details input form.

Data: user_data (same as page_search)

page_payment – fires depending on the payment solution being used, when the payment information is displayed.

Data: payment_data (payment_processor), booking (JSON object of booking – may be provisional or final, depending on whether payment is required or optional)

booking_completed – fires when booking is final and completed, this usually happens in combination with the ‘page_thanks’ event. However, if payment is set as optional, it might fire in combination with the ‘page_payment’ event.

Data: booking (JSON object of completed booking)

page_thanks – fires when displaying the confirmation page.

Data: booking (JSON object of completed booking)

Below is an example that can be used to explore the different available events and associated data. Make sure to replace “data-form-id” with your own booking engine ID.

Example code

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

<html>

<head>

<script>

functioncustomEventHandler(data)

{

//Handle the possible events coming

if(data.event=='page_search')

{

// This will fire every time the first step showing the search form is loading.

// Data will contain the selections made by the guest if returning from subsequent steps,

// otherwise it will contain the default values.

//echoing just to demonstrate access to it

console.log('"page_search" registered');

console.log('Arrival: '+data.user_data.arrivalDate);

console.log('Departure: '+data.user_data.departureDate);

console.log('Adults: '+data.user_data.totalAdults);

console.log('Category: '+data.user_data.category);

}

if(data.event=='page_results')

{

// This will fire when search results are displayed.

// Data will contain the selections made by the guest.

//echoing just to demonstrate access to it

console.log('"page_results" registered');

console.log('Arrival: '+data.user_data.arrivalDate);

console.log('Departure: '+data.user_data.departureDate);

console.log('Adults: '+data.user_data.totalAdults);

console.log('Category: '+data.user_data.category);

}

if(data.event=='page_details')

{

// This will fire when rooms have been selected and guest details are requested.

// Data will contain the selections made by the guest.

//echoing just to demonstrate access to it

console.log('"page_details" registered');

console.log('Arrival: '+data.user_data.arrivalDate);

console.log('Departure: '+data.user_data.departureDate);

console.log('Adults: '+data.user_data.totalAdults);

console.log('Category: '+data.user_data.category);

}

if(data.event=='page_payment')

{

// This will fire when payment information is displayed (might fire more than once).