How can I get the referring domain as a hidden field when someone submits a form in Webflow?

Published on
September 22, 2023

To get the referring domain as a hidden field when someone submits a form in Webflow, you can follow these steps:

  1. Create a hidden field: First, you need to add a hidden field to your form. To do this, go to the form settings, click on the "Add Field" button, and select "Hidden" from the field type options. Give the field a name, for example, "Referring Domain".

  2. Add custom code: After adding the hidden field, you'll need to add some custom code to populate the value of the referring domain. Click on the "Custom Code" button on the left-hand panel of the Webflow Designer.

  3. Insert the JavaScript code: In the custom code panel, insert the following JavaScript code:

<script>  var referrer = document.referrer;  document.getElementsByName("Referring Domain")[0].value = referrer;</script>

This code will retrieve the referring domain and insert it as the value of the hidden field named "Referring Domain".

  1. Save and publish: Once you have added the custom code, save your changes and publish your Webflow site for the changes to take effect.

Now, whenever someone submits a form on your Webflow site, the referring domain will be captured and sent along with the form submission as a hidden field value.

Incorporating the referring domain as a hidden field in your form submissions can provide valuable insights into where your leads or customers are coming from, allowing you to analyze the effectiveness of your marketing efforts.

Additional Questions:

  1. How do I add a hidden field to a form in Webflow?
  2. What is the purpose of a hidden field in a form?
  3. How can I track the source of form submissions in Webflow?