Passing the session source to a hidden field of an unbounce form

It works fine if you go directly to to the form with a campaign link. But if you go to the website first and then click the button to get to the form – the source is gone from the url and so doesn’t get added to the field.

I came up with a solution that rewrote the button link on dom load to append with a new parameter name whatever campaign parameters they arrive with. However – that will only work if they land on one page and go to the form. I could keep making the tag more complicated to cover more situations and that might be the right path.

But I would like to know if there is an easier solution at the source by adding a tag that only triggers when the form loads and pulls the referrer or utm_source and puts it into the hidden field.

Does this make sense what I’m trying to do?

Thank you