Populating hidden form fields with information stored in cookies

Hello!
We are using this to gather a cookie id and identify page view logs, super excited to have gotten the code to work.
However now we’d like to have this on all of our landing pages, and therefore add it to a template and not have to put in the form code (since people use different forms on the page). Can we have this trigger for any form on the page? Or get the form id as a variable that’s already present on the page?
Thanks!

Alivia