Launch a script from a button click

I use 17Hats as my CRM, and they have a cool lead creation form modal thing triggered by clicking a link. Clicking the link triggers a script. I’m trying to figure out how to use the button within Webflow with this script.

Has anyone successfully launched a script from a button click, or know how I might go about doing this?

I did see the exact question in another post, but that post went in the direction of creating a modal. I don’t need to create the modal as 17Hats has already done that…I just want to launch the script triggered by the button click.

Currently I’ve just placed the code into an embed block and styled it manually, but I would love to take advantage of Webflows button block or styling a div.

Anyone have any ideas for things I can try? :smile:

Here is my website: www.letgreg.com and the current implementation is just above the footer.

Really? no one replied to this? I have the same questions. Want this code to work on submit
Submit

// Add Pixel Events to the button’s click handler

Hey @Samphittle & @gksargent these click events are usually triggered based upon the button ID. So if you have the ID setup for a button element (go to the element settings tab and give it an ID name). As well as the script needs to be added to the "before </body>" custom code section at the page level or site wide level.

Do keep in mind that ID’s are Case Sensitive.

How to set an element’s ID:

Hope that this helps get you pointed in the right direction :smile: