Is it possible to create a hidden form field in Webflow that can automatically capture the URL or specific page section from which it was launched and include it when the form is submitted?

Published on
September 22, 2023

Yes, it is possible to create a hidden form field in Webflow that can automatically capture the URL or specific page section from which it was launched and include it when the form is submitted. This can be achieved by using custom code and JavaScript within your Webflow project. Here's how you can do it:

  1. Open your Webflow project in the Designer.
  2. Navigate to the page where you want to add the hidden form field.
  3. Add a new HTML Embed element to your page. You can find this element in the Add panel on the left side of the Designer.
  4. Double-click the HTML Embed element to open the code editor.
  5. In the code editor, enter the following code:
<input type="hidden" name="referrer" id="referrer" value="">
  1. Save and close the code editor.
  2. Select the form element on your page and go to its settings.
  3. Click on the Actions tab, and then click on the + Add Action button.
  4. Choose the Set Value action from the dropdown menu.
  5. In the Set Value action settings, select the Referrer field you added in step 5 as the target field.
  6. In the Value field, enter the following JavaScript code:
document.getElementById('referrer').value = document.referrer;
  1. Save your changes and publish your site.

Now, when someone visits your website and submits the form, the hidden form field "referrer" will automatically capture the URL or specific page section from which the form was launched. This value will be included when the form is submitted, allowing you to track the referring page or section.

Note: If you want to capture a specific page section instead of the entire URL, you can modify the JavaScript code in step 11 to extract the relevant portion using different methods, such as window.location.hash.

With this hidden form field, you can easily track and analyze where your form submissions are coming from, helping you gain insights into your website's performance and user behavior.

Additional Questions:

  1. How can I automatically capture the URL of the page where a form was submitted in Webflow?
  2. Can I track the specific page section from which a form was submitted in Webflow?
  3. What is the best way to include referral information in a Webflow form submission?