Booking Widget Javascript Events

If you are embedding IntakeQ's booking widget on your website, you can use javascript to listen to widget events and perform your own logic. The most common scenario is to use the "Appointment Booked" event in order to track it using an analytics tool, like Google Analytics. Let's look at how to listen to these events.

"Widget Loaded" Event

As you probably guessed, this event is triggered when the booking widget has been loaded successfully on the page. In order to listen to this event, simply add an "intakeqWidgetLoaded" event listener to the same page where the booking widget has been embedded.

<script>
document.addEventListener("intakeqWidgetLoaded", function(e) {
    //YOUR CODE HERE
});
</script>

This event can be used to record events like 'Viewed Widget' in your analytics tool.

"Appointment Booked" Event

This even is triggered whenever a website visitor has completed the process of booking an appointment. In order to listen to this event, simply add an "intakeqAppointmentBooked" event listener to the same page where the booking widget has been embedded.

<script>
document.addEventListener("intakeqAppointmentBooked", function(e) {
    console.log(e.detail)
});
</script>

Note that this event will provide the appointment details in the "detail" property of the event argument. By executing the code above, you should get a result similar to this in your console:

{
  "MemberId": "5330eb98c5771921282d2ab1",
  "ClientName": "John Smith",
  "ClientEmail": "john.smith@gmail.com",
  "ClientPhone": "(123) 123-4567",
  "ClientNote": null,
  "Date": "2018-06-21T16:00:00Z",
  "Duration": 60,
  "ServiceId": "e3f20995-3133-4c89-b456-b347a3eb7c7f",
  "Paid": false,
  "FormSent": false,
  "ClientQuestionnaireId": null,
  "Status": 2, // 2 = Confirmed, 1 = Waiting Confirmation
  "PaymentInfo": null,
  "ServiceName": "Follow Up",
  "Price": 75,  
  "LocationId": "1",
  "LocationName": "Office",
  "LocationAddress": "105 Dulgaren St, Hamilton, ON L8W 3Y8, Canada",
  "CouponCode": null,
  "Discount": 0,
  "ClientTimezoneId": "Eastern Standard Time",
  "LocalTimezoneId": "Eastern Standard Time",
  "InvoiceId": null,
  "InvoiceNumber": 0,
  "InvoiceStatus": 0,
  "AdditionalClients": [],
  "DepositPaymentInfo": null,
  "RealDuration": 20,
  "EndDate": "2018-06-21T17:00:00Z",
  "ConfirmationSent": true,
  "LocalDate": "2018-06-21T12:00:00",
  "AmountDue": 75,
  "TotalAmountPaid": 0,
  "Id": "5b29a168cd4cac07d8441b3f",
  "dateFormatted": "Jun 21, 2018 at 12:00 PM",
}

Still need help? Contact Us Contact Us