[How to] Run Custom Code/Scripts on Form Submission



Ever needed a reliable way to fire some javascript on form submission?

This solution will be super handy for anybody looking to do things like: manipulating form data before it’s submitted, or validating form data on submission, or making custom API calls or ajax requests on form submission.

Whatever custom javascript you may have, using this script is a reliable and easy way to ensure it is fired on form submission.

Give’r a whirl! :spinbounce:

How to Install in Unbounce

Click Here for Instructions

:rotating_light: WARNING: YOU ARE ENTERING DEVELOPER TERRITORY :rotating_light:
This is not an official Unbounce feature. This functionality is based entirely on third party code, and has only been tested in limited applications. Since this isn’t a supported Unbounce feature, our support team will be unable to assist if things go awry. So if you are not comfortable with HTML, Javascript and CSS, please consider consulting an experienced developer.

You can find the script here:

Step 1.

Copy form_submit.js and paste it in your Javascripts section with placement ‘Before Body End Tag’.

Step 2.

Paste the code you want to execute under the comment //ADD CUSTOM CODE HERE on line 5.

Step 3.

YOU’RE DONE! Wow only 2 steps! :noah:

Can’t see the instructions? Log-in or Join the Community to get access immediately. :rocket:

Want to take your Unbounce landing pages + Convertablesâ„¢ to the next level?
:spinbounce: Check out the Ultimate List of Unbounce Tips, Scripts & Hacks

Calling Custom Javascript function on form submit
Using jQuery to prevent lead form being submitted
Data validation
Custom form, keeping unbounce conversion

Nice one, Noah! Excited to see how this may help conversion rates! :chart_with_upwards_trend:

The Ultimate List of Unbounce Tips, Scripts & Hacks
The Ultimate List of Unbounce Tips, Scripts & Hacks

Hey Noah,

Thanks for this script! This is going to be super helpful for an API call I have to make.

Thanks again!


I posted an update to github with some fixes. https://github.com/BillRothVMware/UnbounceJSSubmitCode