Form field filled based on previous page

Hi - I am needing help with a form. What I am wanting to do it the previous page that they were on I would like it to fill in a field on the form based on that previous page. For example: If someone is on a product page and clicks on contact us, when it comes over to the contact us page I would like a field to pull in the previous page into that field.

I was looking for the exact same thing and found it in this post. I hope it helps: