APIs & Integrations

Annie-L
Participant

Integrating custom code into forms

SOLVE

Hi, 

 

I'm trying to integrate a custom code into a form I made but can't seem to find out where to add the code. The code needs to be linked to a hidden form field to capture a unique shortcode from the URL and campaign ID associated with the URL. 


I know this is possible because I have heard of people doing this on Hubspot but can't seem to figure out how. 

0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Integrating custom code into forms

SOLVE

Hi @Annie-L,

 

I hope all is well with you 😄

 

Are you looking to customize the form embed code to manipulate the values of form inputs? If that's the case, you can refer to this documentation here: How to customize the form embed code.

 

Additionally, as mentioned by Derek here: HubSpot Community - Help with Hidden Fields in Forms - HubSpot Community,

"You can use jQuery to update the value of the hidden fields, like this:
$('input[name="firstname"]').val('Brian').change();".

 

Hope this helps to further clarify things!

View solution in original post

0 Upvotes
4 Replies 4
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Integrating custom code into forms

SOLVE

Hi @Annie-L,

 

I hope all is well with you 😄

 

Are you looking to customize the form embed code to manipulate the values of form inputs? If that's the case, you can refer to this documentation here: How to customize the form embed code.

 

Additionally, as mentioned by Derek here: HubSpot Community - Help with Hidden Fields in Forms - HubSpot Community,

"You can use jQuery to update the value of the hidden fields, like this:
$('input[name="firstname"]').val('Brian').change();".

 

Hope this helps to further clarify things!

0 Upvotes
Annie-L
Participant

Integrating custom code into forms

SOLVE

Hi Wendy, 

 

Thanks for that. From my understanding, jQuery is the coding language? Where can I add this code?

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Integrating custom code into forms

SOLVE

Hi @Annie-L,

 

That is right. You can add the code in your form embed code which you can copy it after clicking the 'Share' button and for this I'd love to share with you this documentation here: Share a HubSpot form on an external site.

0 Upvotes
Annie-L
Participant

Integrating custom code into forms

SOLVE

Awesome, thanks for the help Wendy! 🙂

0 Upvotes