Version: 2.0.9
JS library for easy online booking, contact form, and voucher integration
In your HTML document,
- include the
dist/onlinebooking.js
script - add an element where you want the integration to appear
- give the element a unique ID, i.e.
< div id="recras-onlinebooking"></div>
- initialize the script like this:
var options = new RecrasOptions({
recras_hostname: 'demo.recras.nl', // Required
element: document.getElementById('recras-onlinebooking'), // Required
});
new RecrasBooking(options);
In your HTML document,
- include the
dist/onlinebooking.js
script - add an element where you want the integration to appear
- give the element a unique ID, i.e.
<div id="recras-vouchers"></div>
- initialize the script like this:
var options = new RecrasOptions({
recras_hostname: 'demo.recras.nl', // Required
element: document.getElementById('recras-vouchers'), // Required
});
new RecrasVoucher(options);
See the section Options below for an overview of all options
In your HTML document,
- include the
dist/onlinebooking.js
script - add an element where you want the integration to appear
- give the element a unique ID, i.e.
<div id="recras-contactform"></div>
- initialize the script like this:
var options = new RecrasOptions({
recras_hostname: 'demo.recras.nl', // Required
element: document.getElementById('recras-contactform'), // Required
form_id: 4, // Required
});
var form = new RecrasContactForm(options);
form.showForm();
See the section Options below for an overview of all options
See /demo/index.html
for integration demos
recras_hostname
- required - the name of your Recras, i.e.demo.recras.nl
element
- required - a single HTML element, usinggetElementById
orquerySelector
locale
- optional, defaults to nl_NL - a valid locale (de_DE, en_GB, nl_NL, and sv_SE). This is used for country names, error messages, etc. Package names from Recras are not affected.analytics
- optional, defaults tofalse
- set totrue
if you want to enable Google Analytics integration.analyticsEvents
- optional - a list of events to track.analytics
must be set totrue
for this to work. If omitted, all events will be sent. For a list of events, refer to the section Events at the end of this document.
package_id
- optional - can be the following:- the single ID of a package. This will pre-fill the package and skip the package selection dropdown step.
- an array of multiple package IDs. This will only show the selected packages in the package selection dropdown. If there is only one package in the array, it will behave the same as the first method.
redirect_url
- optional - the URL to redirect to after a successful online booking. The URL will receive the created booking ID asboeking_id
GET parameter (i.e.?booking_id=42
). For more information on our booking API, we refer to our booking API documentation.autoScroll
- optional, defaults totrue
- whether or not to scroll the amounts form into view when changing packages. This is most useful if you select a package by default and don't want to scroll past the intro text, set it tofalse
in that case.previewTimes
- optional, defaults totrue
- whether or not to preview times for each line in the programme after selecting a date and time.productAmounts
- optional, use in combination with a singlepackage_id
. Set this to an object where the keys are the package line ID's and the values are the amounts to enter, i.e. :The package line ID's can be obtained by inspecting the amounts form, or by checking the packages API specification - use the{ bookingsize: 16, 1: 12, 42: 16, 43: 16, }
id
field for each entry inregels
.date
- optional, use in combination with a singlepackage_id
. Set this to an ISO 8601 date (e.g. "2021-06-28") to prefill the date. If the selected date is not available for the chosen package or selected products, the date selection will be visible.time
- optional, use in combination with a singlepackage_id
. Set this to a 24-hour time string (e.g. "16:00") to prefill the time. This can be used in combination withdate
, but this is not required. If the selected time is not available for the chosen date, the time selection will be visible.
voucher_template_id
- optional - the ID of a voucher template. This will hide the template selection dropdown and skip this step.redirect_url
- optional - the URL to redirect to after a successful payment. The URL will receive the created booking ID asboeking_id
GET parameter (i.e.?booking_id=42
). For more information on our API's, we refer to our booking API documentation and voucher API documentation.
form_id
- required - the ID of the form.package_id
- optional - can be used to programmatically fill a "Booking - Package" field present in the contact form.defaultCountry
- optional - used to set the default value of a "Contact - Country" field present in the contact form.redirect_url
- optional - the URL to redirect to after a successful form submission.
The library provides a bit of styling to make it look okay straight from the box. If you wish to customise the layout, you can. Just style the appropriate elements from your website's CSS.
This library does not support old browsers (Internet Explorer, pre-Blink Edge, old Safari versions).
The library sends out a few custom events when certain things change:
Recras:Booking:Reset
- when the entire form is resetRecras:Booking:PackagesShown
- when the list of packages is shownRecras:Booking:PackageChanged
- when a new package is selectedRecras:Booking:ProductsShown
- when the products are shown after a package is selectedRecras:Booking:ContactFormShown
- when the contact form is shown after a package is selectedRecras:Booking:DateSelected
- when the date is changedRecras:Booking:TimeSelected
- when the time is changedRecras:Booking:BuyInProgress
- when the online booking form is submittedRecras:Booking:RedirectToPayment
- when the user is redirected to the payment providerRecras:ContactForm:Submit
- when a standalone form is submittedRecras:Voucher:TemplateChanged
- when a new voucher template is selectedRecras:Voucher:BuyInProgress
- when the voucher form is submittedRecras:Voucher:RedirectToPayment
- when the user is redirected to the payment provider
You can use these events for custom actions, such as analytics. For use in code, please refer to the constants in src/eventHelper.js.
When Google Analytics integration is enabled, certain events are sent to GA. Which events are sent depends on the version of GA you are using. For Universal Analytics (v3) and older, these custom events are sent and they include a label and/or value:
Event | Label | Value |
---|---|---|
Recras:Booking:PackageChanged |
Package name | Package ID |
Recras:Booking:DateSelected |
Selected date, in ISO 8601 format | N/A |
Recras:Booking:BuyInProgress |
Package name | Rounded total amount of the booking |
Recras:Booking:RedirectToPayment |
N/A | Rounded total amount of the booking |
Recras:ContactForm:Submit |
N/A | Form ID |
Recras:Voucher:TemplateChanged |
N/A | Template ID |
Recras:Voucher:BuyInProgress |
Template name | Rounded total amount of the order |
Recras:Voucher:RedirectToPayment |
N/A | Rounded total amount of the order |
For GA4, these events are sent:
- when a package is selected:
select_content
. The ID of the package is included. - when a voucher is selected:
select_content
. The ID of the template is included. - when the user is redirected to the payment provider:
begin_checkout
. The total amount as well as all selected items (name, price, quantity) are included.