The client has a complicated form setup.
I attached the event to the on-change event of the email input instead. This actually works because we will only want to capture a lead with an email, so the email input is the perfect place to set it up. I also added a checking mechanism to check if the event listener has already been added. This prevents duplicate issues that might arise by firing multiple times.
setInterval(function() {
jQuery('input[id^="bookly-email-"]').trigger('change');
}, 1000);
var counter = 0;
jQuery(document).on('change', 'input[id^="bookly-email-"]', function(event) {
if (counter === 0) {
console.log('Capture lead event listener added');
counter = 1;
jQuery('button.bookly-js-next-step').on('click', function(event) {
// Your code here
});
jQuery('button.bookly-js-back-step').on('click', function(event) {
counter = 0;
});
}
});
Can fire a faux form to capture the lead.
Ticket: Link