KWIGA help center Services, integrations, API, Settings Services Handling a button click in the widget

Handling a button click in the widget

Articles:

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.