Insert Cookie Value Into Hidden Form Field

Hi Webflow Community,

I am interested in taking the value of a first-party cookie (I have been successful in setting such a cookie in the browser) and insert it into a hidden field in a standard Webflow Form. I am able to create the cookie (taking values from a URL query) using Google Tag Manager and store it in browser. However, I have tried many attempts at using some sort of script to insert the cookie value into a hidden form field with no success. I can verify that the cookie is stored, but have been unsuccessful in populating a hidden form field with the cookie. The page I would like to do this:

The code I attempted to use to insert cookie value into field based on previous success:

   document.getElementById("urlsource").value = readCookie("source");

where the hidden field in the form looks like:

<input type="hidden" class="urlsource" id="urlsource" value="">

I have done this many times successfully using a different site builder, and would love to get this working on my Webflow site! Any help would be much appreciated!


Hi Steven,

Welcome to the forum!

I have successfully implemented hidden form fields by using normal <input> fields inside a HTML embed element, then hiding the HTML embed using a class set to hidden, but I’m not sure if adding cookies would have a different process.

Would you mind sharing your read-only link so the community can take a closer look?

Hi! and thanks for responding. Here’s the link to my project. Click Contact Us to get to the page with the form…:

Perfect, thanks @techtowerdigital!

So just initially maybe you could test what I mentioned above and see if that happens to work, but otherwise maybe there’s another community member that knows more about adding cookies to forms who could help further :slight_smile: I will ping the other community experts also to see if they know of any tricks here.

Hope your week is off to a great start!

I have tried a few variations of what you mentioned… nothing appears to work yet! I’ll look out for responses from the other community members.

Thanks again!

1 Like

Sorry I wasn’t able to be of more help. I asked the other community experts but looks like none of them have been able to address yet. Hope someone can figure this out for you soon.

1 Like