If you are using Ajax to submit forms on your website, or have a form validation script that must be confirmed as complete prior to submission, you will likely need to change the submit type for the SharpSpring native form tracking script to manual submit. Follow the steps below to add a manual submit option to your native form tracking script.
The following User Roles can access form code in SharpSpring:
- Marketing Manager
Step By Step Instructions
Step One: Add an ID to the native form we will be tracking. The ID is an attribute of the form tag. We will need this in order to tell the Native Form script which form data to grab from the page.
Step Two: Create a Native Form in SharpSpring. We will need to make a few edits to this script. Copy the code and place in a text editor (Atom, Brackets, etc.) An example of a Native Form script is below.
Step Three: Edit the Native Form script. Make the following changes:
- On line three, change 'endpoint' to 'form'
- On line three, add a parameter for our form ID directly after 'form'
- Add a line four consisting of: __ss_noform.push(['submitType', 'manual']);
Below is an example of the Native Form script with the above edits made, using 'myform' as our form ID.
Step Four: Add the below line to your site. This must be called after the script above, when we are submitting the form. Note that the final string in this line must be the same string that we have in line three of the Native Form script from Step Three.
This needs to be run from within your own form submission code, and should not be run on page load. This line should be run once any validation for the form has passed, but before the form is removed from the page.
NOTE: The use of 'null' in the above will work in most situations, but if something needs to happen only after our code has finished submitting the form, this parameter can instead be a callback function. Below is an example of using a callback to change the page: