Hi everyone,
We’re working on a project and need to trigger custom server-side actions after a HubSpot form submission, specifically:
- Creating a WooCommerce order
- Creating a user account in affiliate tracking tool called iDevAffiliate
We’ve followed the HubSpot documentation and have already contacted HubSpot support. We also implemented all their suggestions, including the modified code they provided:
<script charset="utf-8" type="text/javascript" src="https://js.hsforms.net/forms/embed/v2.js"></script>
<div id="hubspotform"></div>
<script>
hbspt.forms.create({
portalId: "---------",
formId: "---------",
target: "#hubspotform",
onFormSubmit: function(form) {
// Correct parameter: 'form' (not '$form')
console.log("HubSpot onFormSubmit triggered.");
console.log("Form Data:", form.getData());
// Our intended custom actions
// 1. Trigger WooCommerce order creation
// 2. Send data to iDevAffiliate to create user
}
});
</script>
Despite using this version, none of the custom logic is executing — we’ve tested with both onFormSubmit and onFormSubmitted.
Our developer has also tried alternative approaches to make this work but hasn’t had any success so far.
What we need help with:
- What is the correct and reliable way to execute custom backend logic (e.g. WooCommerce + iDevAffiliate) after a HubSpot form is submitted?
- Are onFormSubmit or onFormSubmitted suitable for this, or should we trigger something using a webhook or workflow instead?
- Are there any known limitations or additional considerations with using these callbacks for embedded forms?
Any help or working examples would be really appreciated. Thanks in advance!
Best regards,
John
