If you're looking for an easy way to do it, we just released a plugin that does exactly what you just laid out.
It effectively gets the same data as GA4, and adds that to hidden fields on your contact form.
https://themekraft.com/plugins/lead-source-magic/