Hi @alivia !
Great to hear you have that working!
After some testing around this I found that you could hypothetically have this on a page template or JS file to trigger on many pages but there are some things to keep in mind around that:
Firstly you’ll want to ensure you use something like window.onload to ensure the scripts only load after the form has fully done so - otherwise you might error in the script by trying to assign a null cookie/valid value to a field that doesn’t exist.
The other thing to keep in mind is that if you don’t have a form on the page and you add this to a script it would throw errors because it’s attempting to run for fields that don’t exist.
Otherwise you could have a form with hidden fields you want to pass values to, and in the template markup you could have an onload function that adds any values you need to those hidden fields.
One last thing worth mentioning is that changing values on the page level when the code is on the template or a JS file will only work if the fields are hidden. From testing it looks like this is down to how the form gets field values from visible versus hidden fields. If you wanted to modify visible fields you will need to edit the embed code. So if you were attempting to test this with the fields visible first it’s worth noting it won’t work - it will only work for hidden fields!
Hopefully that helps ![]()