There are some cases in which a form might not fire a submit action for the Lead Gen & CRM Native Form code to capture, or may fire it in a way that the code does not properly recognize. Some examples include using Ajax to submit forms on your website, certain validation scripts that need to run before submitting to Lead Gen & CRM, or your submissions to Lead Gen & CRM are being interrupted by a page change.
This article will detail how to add a manual submission option to your native form tracking script in the event that this happens.
Article Contents
Trial | ✓ | |
Essential | ✓ | |
Advanced | ✓ | |
Ultimate | ✓ |
Administrators | ✓ | |
Company Managers | ||
Marketing Managers | ||
Sales Managers | ||
Salespersons | ||
Jr. Salespersons |
Adding Manual Submission to Native Forms
Manual submission is required for native forms with submit buttons that are wrapped in a <button>
tag.
To add manual submission to native forms, do the following:
- Add an ID to the native form that will be tracked. The following is an example of a native form ID.
- Create a native form in Lead Gen & CRM.
- Copy the form code and place in a text editor, such as Atom or Brackets.
- Change
'endpoint'
to'form'
in the form's code. - Add a parameter for the form ID directly after
'form'
in the form's code.
The following is example code with'myform'
as the form ID and the endpoint value following it:
<script type="text/javascript"> var __ss_noform = __ss_noform || []; __ss_noform.push(['baseURI', 'https://app-2GCK1V3Z33.marketingautomation.services/webforms/receivePostback/WxviTCKbWEDiVzA/']); __ss_noform.push(['form', 'myform', '1234io3l-c442-8c9e-1234-9933b6n1gi6s']); __ss_noform.push(['submitType', 'manual']); </script> <script type="text/javascipt" src="https://koi-2GCK1V3Z33.marketingautomation.services/client/noform.js?ver=1.24"></script>
- Add a line consisting of
__ss_noform.push(['submitType', 'manual']);
before the first closing</script>
tag in the form's code. - Add the following line to the code that handles the submission of your form once it is filled out:
__ss_noform.push(['submit', null, '1234io3l-c442-8c9e-1234-9933b6n1gi6s']);
As this line of code triggers the submission to Lead Gen & CRM, be aware that this code should not be run on page load, but instead triggered as part of your form submission process.
Additional Considerations
The use of 'null'
in the code will work in most situations, but if something needs to happen only after the code has finished submitting the form, this parameter can instead be a callback function.
__ss_noform.push(['submit', function () {window.location = 'http://mysite.com/thank-you';}, '1234io31-b123-8c8e-1234-9999a3n8g21b']);
When using manual submission code, adhere to the following:
- The supplied code must be called after the script above when submitting the form.
- The final string in the supplied code must be the same string in line three of the native form script.
- The supplied code needs to be run from within your own form submission code, and should not be run on page load.
- The supplied code should be run once any validation for the form has passed, but before the form is removed from the page.