When a webform is submitted, the system emits an event called 'SM_FORM_SUBMITTED'. You can add a listener in your code for this specific event and execute any additional code that is required.
SM_FORM_SUBMITTED
Add Listener:
For example,
window.addEventListener("SM_FORM_SUBMITTED", function (e) {
console.log('Form Name:', e.detail.formName, 'Form Data:', e.detail.formData);
});
If you add code like displayed above in your website, then you will get a similar output as shown below.
Result:
Form Name: Demo WebForm
Form Data:
{
"Contact.name": "Damon",
"Contact.email": "damon@example.com",
"Contact.mobile": "98765XXXXX",
"Contact.multiSelectCustomField14": [ "Sales", "Marketing" ],
"Deal.pipeline": "Premium",
"Deal.title": "Demo Cost"
}
This can be be used for external tracking. For example:
window.addEventListener('SM_FORM_SUBMITTED', function($form) {
if ($form.data.txtCustomField1 == 'Yes')
{ window.location = 'https://example.com/career'; }
} );
The above code demonstrates how you can use the event to redirect the customer at certain URL when they choose a value for some specific field.
Comments
0 comments
Article is closed for comments.