Custom HTML Form Scripting



After reading a quick answer about custom forms I still need some clarification, on this point:

Our API requires the use of a server-side script that executes when a user submits the form. This custom script’s url would be added to the action attribute of your HTML form.

I am interested in using JS to subscribe to the submit event of a custom HTML form, perform some operations and and then allow the form be submitted, successfully creating/updating a contact.

Yet, I’m confused with the reference to “server side script” it makes it seem I need to actually the form post to application (instead o hubspot API or something), or are these server side scripts a feature I’m not aware of?

Thanks in advance,


Hi @jhenriquez,

Let me see if I can clarify for you. If the form is simply going to your server, you don’t need to worry about anything. However if you want to tell HubSpot about that Form submission (and I assume you do), then you need to use a server-side script to do that. This is because HubSpot’s API does not accept Cross-Origin Requests.

Let me know if you need additional clarification.



Hello @zwolfson

I appreciate your quick answers. It did clarify my doubts. I still have one more question, though. I’m already testing, but still using previews of my landing page to do so and was wondering if the hutk should be available on this mode, or only on published pages. Because I’m not getting it, with my custom form’s post request.

Thanks in advance,



That depends on where you are doing your previews and if you’ve connected a subdomain to HubSpot yet. If you are using the live preview inside the app, the cookie won’t be there. If you are using the live preview, the cookie will be on whatever domain you currently have connected to the tool. If you have no domain, it will default to an *.hs-sites domain so it will be a different cookie than.

If you are on a non-HubSpot hosted page, you just need to make sure the tracking code is present as that is what sets the cookie.

Feel free to put a link to the page you are working on if that would help clear things up.



Thanks @zwolfson! I’m not sure about our current domains settings. I’ll check them out and update.


Hello @zwolfson,

Hey, sorry it took me so long come back. I had not had the time to try out. I event went ahead a published the page.

Still got the same results, so I went and checked our domain settings. We were using which I thought could work for all, including sub domains. But I did change it to (just for the sake of testing) and still I’m not getting the cookie.

Also, I think is important to point that I’m using NodeJS (with express) and by not getting the cookie I mean, it’s not being listed in the request.cookies hash.

Thanks in advance,


@jhenriquez, thanks for the link the the page, I think I see what’s going on now. I may be missing something obvious but I think that it’s because your form handler is on a different domain. When I checked the network tab (I signed up, hope you don’t mind) the request headers for the POST had the cookies for the destination domain, not the source domain. If you connect your node app to a subdomain of your domain it should work correctly.



Hey, got pulled to other features, I apologize it took me so long to go over your last reply. No worries about signing up, I really appreciate you taking the time to go check it out.

Well, first thing is I had not checked the outgoing request, good call there. But now that I see it, none of the cookies there are domain specific and that’s sort of weird. I would have expected the request to contain at least a domain specific cookie, that could justify why I was not able to access it on my c9 domain.

I think I can set up a testing version of our app in a subdomain and attempt the same test. So, just to confirm I’m following here:

Considering my landing page is on: , if I setup a staging version of my application on let’s say and have my landing page redirect to that one. Should the analytics cookie be present?

Again, I really appreciate your kindness and patience, thanks!