In your Webflow form, create another text field. Give it an ID of utm-field. Now set it to display none so that users don’t see it. Make sure that it is not set to required (in case there is no UTM data to enter).
Next you will need a script that will get UTM parameters from the URL on page load, then put these into the form field. You would put this in the body code of your page:
This example puts all UTM parameters into 1 field, you could of course alter this and create multiple form fields to input each specific UTM parameter.
Thank you for writing this explanation. I’m trying to solve the same problem (pass UTM values to hidden fields on a form). I’m a new user of Webflow…
Could you modify this script so that each UTM value (Medium, Content, etc) goes to its own hidden field? So utm_medium → UTM Medium field, etc…
Also, when you say to add the script to the body code of the page, do you mean to just add an “Embed” element anywhere on the body, then make it not visible, or do we need to add this script on the Project Settings?
Thanks for the quick reply. I created a field for each UTM value, could you rewrite the script so the value from the URL (utm_medium, utm_content etc) gets pushed to the fields? I’m not good at editing scripts
This is how I was entering the code (embed element directly on the form page, not visible):
I don’t know if you managed to solve this, but I stumbled across this just now and for completeness to anyone else searching this topic offer the following that we use in one of our projects:
The below works on a url like: Example Domain and with a field named keyword
The last three lines can be duplicated as you need to in order to separate out and place any other values you have. I can’t remember why we explicitly pull out individual params in this example instead of for-each-ing it but there was a reason it’s a working and simple example though.
Thank you for your code, it’s really simple and very well explained. Let me ask you a question. Our visitors will be landing on the product page and they will bring UTM parameters with them. My issue is that there is no form in my product page other than the Buy Now button (Option list element) that will send them to the checkout page. Is it possible to carry the UTM over to the Checkout page and then submitted with the order when the user clicks on the “place order” button?
Thank you in advance for any guidance you can provide.