Articles:
- Data export to Google Sheets
- Connecting the FB Pixel to a project on Kwiga
- Sending a webhook to transfer data to another service
- Zoom integration and usage essentials
- Generating payment links with pre-filled data
- Handling a button click in the widget
- Sending a webhook to KeyCRM with separation of the application and payment.
Learn how to handle button clicks in a widget, enabling smooth interactions and enhanced functionality on your website.
If you need to add extra button handling in JavaScript before the form is submitted/the link is followed, you can use the following approach.
Buttons in the widget have the class widget-button and when clicked, they trigger a custom JavaScript event named widget-button-click .
An example of code that adds an event handler for widget-button-click on all widget buttons (elements with the class widget-button ) and sends the AddToCart event to the Facebook pixel (note: if your button submits a form, then the Facebook pixel event can be configured in the button settings in the widget builder).
The script can be placed anywhere in the document.
const checkButton = setInterval(
function () {
const widgetButtons = document.querySelectorAll('.widget-button')
if (widgetButtons.length) {
widgetButtons.forEach(function (node) {
node.addEventListener(
'widget-button-click',
function () {
window.fbq && window.fbq('track', 'AddToCart')
}
)
})
clearInterval(checkButton)
}
},
1000
)
Didn't find the answer? Contact the support service via online chat or Telegram