Custom Form Submission


#1

I built a custom form for a website which you can access here. Is there a way I can use this form I have built and submit the form data to hubspot? Having a hard time figuring it out through api form docs. Any examples or more information would be really helpful. Thank you


#2

@Tim_Garlick Where are you getting stuck? Here is the correct page in case you were looking elsewhere. http://developers.hubspot.com/docs/methods/forms/submit_form
Do you know what server side language you are writing it in? There are examples in PHP, C#. VB, and NodeJS in the docs.


#3

I am basically just copying over the php code from that link you sent me. I am running into issues with the end point. If I custom code my own form what end point am I supposed to be pointing my form to? What action should I be putting down on my form? I was able to quickly throw something together when creating a form through hubspot but not my own form. I dont know what guid to put down or portal id to put down. Sorry I am new to hubspot so any added help would be appreciated.


#4

@Tim_Garlick Your portal ID will be in the top right of your screen when in HubSpot.


The Form guid you can grab in the URL when you have it up in the forms tool.

The end point you need to hit was the link I sent you. Here is the example of it. https://forms.hubspot.com/uploads/form/v2/:portal_id/:form_guid
I think you just need to figure out your portal ID and Form ID. Then you should be good when making that call to the endpoint.


#5

Thank you for the reply. So to clarify I did not create my form through hubspot but just custom coded it on a website. That is where I am getting thrown off on the form guid. Do I need to create the form through hubspot to get that guid or how would I go about getting that without creating a form through hubspot?


#6

@Tim_Garlick Yes you need to create a matching form in HubSpot. That way the info you send from your custom coded form has a “home” when you send the data to HubSpot.


#7

OK that sounds good. Do I need to include the Javascript link? The reason why I am having a hard time is because the form I created has so much custom styling and javascript coded into it. Its not a typical form otherwise I assume this would me pretty straightforward.


#8

@Tim_Garlick Which Javascript link are you referring to? The tracking code?


#9

I think I figured that part out. I am now getting a 204 response when I send my form; However, no data is being captured and when I try to add a multi select checkbox I get a concatenation error. On my form I have multiple inputs that are both radio select and multi select. I will post my code example. In my form my first input is and other inputs with the same name but other values that follow. In my php code I get a concatenation error. My php code is $str_post = “industry=” . urlencode($manufacturing;$asset_tracking;$distribution;$service;warehouse) with many others that follow. I have everything set up on the hubspot forms to match the same name and value pairs. Not sure where I am going wrong. Anything you can see?


#10

@Tim_Garlick I’m guessing there should be only one variable associated to it. You should have one variable that will hold there answer regardless of what it is. Then pass that. Also it looks like you for the ‘$’ in front of warehouse. Can you grab the selected response to the multi checkbox? That way you don’t have to pass every response whether they clicked it or not.


#11

would It be something like this? I dont have access to the server right now otherwise I would test it. Here is the example I just found on stackoverflow.

<input type=“checkbox” name=“check_list[]” value=“value 1”
<input type=“checkbox” name=“check_list[]” value=“value 2”
<input type=“checkbox” name=“check_list[]” value=“value 3”
<input type=“checkbox” name=“check_list[]” value=“value 4”
<input type=“checkbox” name=“check_list[]” value=“value 5”

and then in the php code do

$str_post = “check_list=” . urlencode($check_list) if not is there an example you can show me or point me to? also I didnt close my inputs on purpose because when I did it wouldnt show up on the post


#12

@Tim_Garlick THe best example is here on our docs.

The problem with using checkboxes is that they could click on more than one of them. You can’t assign more than one value to one property in HubSpot. Have you tried using radio buttons instead? Then in Javascript you can get the value of the selected radio button and pass it to your $check_list variable to encode and store in your Industry property.


#13

@Tim_Garlick Do you get the same error if you keep your code the same but add a $ infront of warehouse?
so it would be.

$str_post = “industry=” . urlencode($manufacturing;$asset_tracking;$distribution;$service;$warehouse)


#14

yes its giving me a concatenation error. I am not sure what part of my syntax is incorrect


#15

@Tim_Garlick You need this at the end of that $str_Post line. I am not sure if that will solve the concatenation issue but it is one thing we need to edit.

. "&hs_context=" . urlencode($hs_context_json); //Leave this one be


#16

I copy the code the link you provide for node js but in response I get this. Problem with request Error: read ECONNRESET. while using php it runs fine.
The complete code will be available @ https://stackoverflow.com/questions/52200201/hubspot-integration-with-nodejs