Hey, I might be completely blind but I am struggling to work out exactly where in HubSpot I am supposed to add onFromSubmit handlers for forms created using the Marketing Form Builder. I see a lot of examples for using
hbspt.forms.create({
portalId: '',
formId: '',
onFormSubmit: function($form) {
// YOUR SCRIPT HERE
}
});
however there seems to be no place to add this code. I attempted to embed it in Settings > Advanced Options > Additional code snippets > Head HTML but understandably hbspt isn't an object.
Am I missing something really obvious?
My use case is that I wish to add a product signup form for a SAAS application and the form must post to an external URL where my webapp sits to create an account.
Any help would be greatly appreciated. I feel that as I can't find an answer the question must be blindingly stupid and look forward to being put on the path to enlightenment
That's what the HubSpot form embed code looks like; the customization options (including the various callbacks) are intended to be used when embedding the form on an external page. If you're trying to take advantage of these events on a HubSpot page, you'd be better off listening for the corresponding global form events:
This is a list of global events triggered by HubSpot forms; you can use these to trigger custom javascript related to forms. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.
You can actually just define the request URL where I typed $(form).attr('action'). Since the embedded form action URL points to HubSpot's backend, you will need to define a different request URL within the onFormSubmit method. That was an oversight on my part.
@lucygenik, what does the final product look like then. I.e., what exactly do you add in the onFormSubmit section here to send the form data to an external url (?):
hbspt.forms.create({
portalId: '',
formId: '',
onFormSubmit: function($form) {
// YOUR SCRIPT HERE
}
});
That's what the HubSpot form embed code looks like; the customization options (including the various callbacks) are intended to be used when embedding the form on an external page. If you're trying to take advantage of these events on a HubSpot page, you'd be better off listening for the corresponding global form events:
This is a list of global events triggered by HubSpot forms; you can use these to trigger custom javascript related to forms. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.