Hola! ¡Tenemos nuestra Comunidad en Español!

Pass HSContent cookie value to hidden form field

Colaborador ocasional

Hi guys, long story short

Im creating a survey with a custom form and I develop with CUSTOM MODULE in hubspot. I finished  the form with the opening like this:

<form id="msform" action="https://forms.hubspot.com/uploads/form/v2/5435007/bb741987-d401-482b-86b3-13ebf0405ec4" method="post">

but when I tried to submit, it said my IP address cookie was not being passed so I have to add a hidden field :

<input type="hidden" id="something" name="hs_context" value="">

I follow this documentation: 



and what I needed to do is pulling the cookie from this REQUEST BODY with the example like this:



Im gonna use javascript to do this task, can someone help me with a full functional code to help me achieve this?


0 Me gusta
1 Respuesta 1
Gestor de la comunidad

Hi @zendersto,


I hope all is well with you 😄


When looking to get the cookie from the hs_context, you can use something like this:

function hubspotCookie() {
  return document.cookie.replace(/(?Emoticono triste?:^|.*;\s*)hubspotutk\s*\=\s*([^;]*).*$)|^.*$/, "$1");


As reference from this documentation: Integrating Hubspot with Inspectlet – Inspectlet.


Hope this helps to clarify!

0 Me gusta