Collecting data from an embedded booking page

Collect data from an embedded booking page with JavaScript

OnceHub allows you to collect booking confirmation data from an embedded booking page by adding a JavaScript function alongside the embed code in your website. The JavaScript function is executed every time a booking is successfully scheduled in your embedded booking page. When the function executes, a JSON data payload object containing booking confirmation data is sent to the parent page (the page in which the scheduling pane is embedded).

This feature can be used to create a custom confirmation page, enable client-side integrations, or enrich customer data profiles, among other applications. Learn more about use cases for collecting data from embedded booking pages

Set up data collection from an embedded booking page

In order to start collecting data from an embedded booking page, you must first publish your Booking page using Website embed. You can do this from the ScheduleOnce > Share & Publish section of your account. Simply copy the embed code generated for your selected Booking page, and paste it into your web page.


Figure 1: Website embed

To implement the JavaScript data collection function, follow these steps:

  1. Implement the SOAfterConfirmationFunction() function by pasting the code into the page in which your scheduling pane is embedded (the parent page). It is recommended to paste this function before the booking page embed code, because the interpreters of some browsers do not support calling undefined functions.
  2. Define the parameter name you wish the function to call (this will be the name of the JSON object returned when the function executes, containing customer booking data). The function takes one parameter.
  3. Implement the logic you wish to apply to the returned JSON object.

The following is an example code snippet showing the implementation of the SOAfterConfirmationFunction() function and an embedded booking page:

  function SOAfterConfirmationFunction(data) {
    // logic using the data object passed to the function

<!-- ScheduleOnce embed START -->
< div id="SOIDIV_dana"
data-style="border: 1px solid #d8d8d8; min-width: 290px; max-width: 900px;"
data-psz="00" > < /div> < script type="text/javascript"
src="" > < /script>
 <!-- ScheduleOnce embed END -->

That’s it!

Now your embedded booking page will send customer data to the parent page every time a booking is scheduled.

Booking confirmation data payload

The following is an example of the booking confirmation data object returned when the SOAfterConfirmationFunction() is executed. The function is executed when a booking is successfully made in an embedded scheduling pane, and the object containing booking data is sent to the parent page (the page in which the scheduling pane is embedded).

The JSON object contains the following booking information represented by key-value pairs (KVPs):

  • Customer name
  • Customer phone number
  • Customer email
  • Event type name
  • Meeting times - UTC, customer time zone, and booking page time zone
  • Cancel/Reschedule link
  • Customer note
  • Calendar event files - ICS and VCS
  • Error status and error codes (if relevant)

Below is a sample booking confirmation data payload:

  "errorStatus": 0,
  "bookingInfo": {
    "Version": "7.35",
    "MeetingTimes": [
        "UTCTime": "2018-04-25T06:45:00",
        "CustomerTime": "2018-04-25T07:45:00",
        "SOTime": "2018-04-25T09:45:00"
    "CancelRescheduleLink": "*B2fXy8foErRlIIiq*-zghumtdE2JkL5lnKoWCA!!",
    "Note": "I look forward to the meeting.",
    "CalendarEvent": {
      "ICS": "",
      "VCS": ""
    "statusCode": "1",
    "Message": null,
    "CustomerName": "John Smith",
    "CustomerEmail": "[email protected]",
    "CustomerPhone": "1-2025550195",
    "EventTypeName": "Automatic booking - 15-minute meeting",
    "BookingId": [

The JSON object returned to the parent page upon execution of the SOAfterConfirmationFunction() function contains an error status (0 = function executed successfully; 1 = function did not execute successfully) and booking information. The following table describes the fields included in the bookingInfo payload:

VersionstringPayload version
MeetingTimes.UTCTimedatetimeThe starting date and time, in UTC.
MeetingTimes.CustomerTimedatetimeThe starting date and time, in the customer time zone.
MeetingTimes.SOTimedatetimeThe starting date and time, in the booking page time zone.
CancelRescheduleLinkurlThe Cancel/Reschedule link sent to the customer.
NotestringThe note provided by the customer in the booking form.
CalendarEvent.ICSurlFiles that can be downloaded and added to a calendar event.
CalendarEvent.VCSurlFiles that can be downloaded and added to a calendar event.
statusCodestringError status: "1" = success; "0" = invalid request. Data can be accessed for a particular meeting only once from this api request.
MessagestringError message. For a server error: "Something went wrong on server". All other cases return "null".
CustomerNamestringThe name provided by the Customer in the booking form.
CustomerEmailstringThe email provided by the Customer in the booking form.
CustomerPhonestringThe phone number provided by the customer in the booking form.
EventTypeNamestringThe name of the service selected by the customer.
BookingIdarray[string]The ID of the booking. In case of a session package, multiple IDs could be returned.


The following constraints are important to keep in mind when implementing the data collection JavaScript function in your embedded booking page:

  • The function will only execute when a booking is scheduled (not canceled, rescheduled, or reassigned).
  • The function is available for use with booking pages published via website embed only (not for website button, website widget, or stand-alone booking pages).
  • For security and privacy reasons, this function does not execute when your OnceHub account is integrated with a CRM and you are using the CRM record ID to skip or pre-populate the booking form.