HubSpot onFormSubmit / onFormSubmitted Not Triggering Custom Actions (WooCommerce + iDevAffiliate)

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

Are you able to see your console logs? Is the page redirecting before you are able to process this?

a better way is using global form events.

onformsubmitted would likely be better.

Hi Nick,
Thanks for your response.
As per my shared my code..I applied only console message no redirection. But unfortunately didn’t work.
Please see attached secreen.


I have checked my logs..But nothing found in console.
I tried ‘onformsubmitted’ and ‘onformsubmit’ both…but didn’t work.
If you can share any functional form reference..that would be more help for me.
Best Regards,
John

Can you share the page url? I can troubleshoot this better if you do.