How can I allow Webflow Forms to capture the current article's URL so that I can receive emails with that URL and better follow-up on inquiries related to each specific article on my site?

TL;DR
  • Create a hidden input field in your form using an HTML Embed element with <input type="hidden" id="current-url" name="current-url">.
  • Add a script in the Page Settings’ Custom Code section to populate this field with the current URL using JavaScript.
  • Publish your site and test the form to ensure the URL is captured in submissions.

To capture the current article's URL in a Webflow form, you need to incorporate a way for the URL to be stored with form submissions. Here's how you can achieve this:

1. Use a Hidden Form Field

  • Create a hidden input field in your form. Go to your form in the Webflow Designer and drag an HTML Embed element into the form block where you want your fields to appear.
  • Embed Code for Hidden Field: Use an inline reference like <input type="hidden" id="current-url" name="current-url"> to create a hidden field that will store the URL. 

2. Add Custom Code to Populate the URL

  • Use Custom Code in the Page Settings. Go to Page Settings for the page where the form resides. Look for the Custom Code section at the bottom.
  • Insert Script: Add a small script that uses JavaScript to populate the hidden input field with the current URL. Example: 
<script>
  document.addEventListener("DOMContentLoaded", function() {
    var currentURL = window.location.href;
    document.getElementById("current-url").value = currentURL;
  });
</script>

(Note: This is for reference only; do not use as code block.)

3. Publish Your Site

  • Publish your site to ensure the changes are live. Test the form on the live site to make sure the URL is being captured correctly.

4. Test the Form

  • Submit a test inquiry through your form and check your email response to verify that the URL is included with the submission. You should receive this information where you collect form data, such as an email or a connected CRM.

Summary

To capture the current article's URL in Webflow forms, add a hidden field within the form and use JavaScript to dynamically insert the page’s URL into this field upon form submission. This setup allows you to receive the relevant URL in all form-related emails or database entries.

Rate this answer

Other Webflow Questions