Injecting data to hidden fields

This is a 2 part questsion:

  1. I have a code that runs via GTM that sets a parameter that I can access via calling (i.e sessionId). I would like to have this parameter value injected into a hidden field so I could grab it along with the rest of the form data. I am able to do this via the console when viewing my site however the actual form field value is not being sent. Is this even possible?

  2. How would I inject URL parameters into hidden fields for the same functionality as the first question?

If you’re using the Wix Form app it may be possible (depends on the form).
If you built your own custom form from scratch the it’s definitely possible (but you can also submit the data without assigning it to an input element).
Any way, if you go for the hidden field, make the input elem hidden and:

import wixLocation from "wix-loaction";
const query = wixLocation.query;
const id = query.id;
//retrieve the GTM
$w.onReady(() => {
$w("#input7").value = gtm;
$w("#input8").value = id;
})

I get how to do this with url querystrings but what if I would like to grab a cookie value and inject that into a hidden field, is that possible?

@eyal26259 you can use browser cache, see:
https://www.wix.com/velo/reference/wix-storage/storage/setitem
https://www.wix.com/velo/reference/wix-storage/storage/getitem

after retrieving the value, assign it to the hidden field.