APIs & Integrations

Not applicable

Events when form is sent

SOLVE

Hi,
I was trying to change the form embedded including an event when the form is sent.
I made this code, but I crashed the form.

I have no idea what could be happening. Is there any problem with the onForm?

Thanks in advance

0 Upvotes
1 Accepted solution
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Events when form is sent

SOLVE

Hi @Vivian,

My test form breaks as well when I place two instances of onFormSubmit in the embed code. If you add the second function within the first onFormSubmit, does it work?

Isaac Takushi

Associate Certification Manager

View solution in original post

0 Upvotes
3 Replies 3
Not applicable

Events when form is sent

SOLVE

Hi @Isaac_Takushi
I used it. I planned like this:

hbspt.forms.create({
portalId: "-----",
formId: "--------------------",
onFormSubmit: function($form) {
analytics.track(‘form send’, {
category: ‘Send’,
label: ‘send contact’
}
)};,
target: '.formPst',
onFormSubmit: function() {
window.dataLayer.push({
event: 'lead_conversion'+window.location.pathname.split(///i).join('_'),
formId: '--------------------'
});
}
});
// ]]>

0 Upvotes
IsaacTakushi
Solution
HubSpot Employee
HubSpot Employee

Events when form is sent

SOLVE

Hi @Vivian,

My test form breaks as well when I place two instances of onFormSubmit in the embed code. If you add the second function within the first onFormSubmit, does it work?

Isaac Takushi

Associate Certification Manager
0 Upvotes
IsaacTakushi
HubSpot Employee
HubSpot Employee

Events when form is sent

SOLVE

Hi @Vivian,

Are you using onFormSubmit per this article?

This method should work. If you're still encountering issues, please include the modified embed code below.

Isaac Takushi

Associate Certification Manager
0 Upvotes