When a web form 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
window.addEventListener("SM_FORM_SUBMITTED", function (e) {
SALESMATE.login({
email: e.detail.formData["Contact.email"],
mobile: e.detail.formData["Contact.mobile"],
name: e.detail.formData["Contact.name"],
});
});
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 on your website along with the Salesmate's webform, then you will get a similar output as shown below.
Here's how the form will look on the website once you will add it.
Here is the example of the HTML code of the form with a listener code:
Once the details have been filled in the form the result could be seen in console tab:
Here's How it would look:
To check the results right click on the web page click on inspect elements and under Console tab your result would be visible.
Here's How the result would look once you would submit the form:
This can be used for external tracking.
For example:
window.addEventListener("SM_FORM_SUBMITTED", function (e) {
SALESMATE.login({
email: e.detail.formData["Contact.email"],
mobile: e.detail.formData["Contact.mobile"],
name: e.detail.formData["Contact.name"],
});
});
Here name, email and mobile are the fields being captured from the form and the exact labels that need to go in the above piece of code.
The above code demonstrates how you can use the event to redirect the customer to a certain URL when they choose a value for some specific field.
Comments
0 comments
Article is closed for comments.