Webflow sync, pageviews & more.
NEW

Is there a simple way in Webflow to automatically include the current URL in a form, without having to edit each form separately and without compromising the ability to use the form as a symbol?

TL;DR
  • Add a hidden input field with a unique ID to your form Symbol.
  • Add a site-wide script in Project Settings that fills the hidden field with the current page URL on load.
  • Save and publish your site to apply changes across all pages while keeping Symbol functionality intact.

Yes, you can automatically capture the current page URL in a Webflow form without editing each form individually or breaking Symbol functionality. This requires adding a custom script that dynamically populates a hidden form field with the page’s URL.

1. Add a Hidden Field in Your Form Symbol

  • Open the Symbol (e.g., your form component) and edit it.
  • Add a form input field and change its type to Hidden in the Element Settings panel.
  • Give the input a unique Name like page-url and a custom ID like form-page-url.

2. Insert Custom Script Site-Wide

  • Go to Project Settings > Custom Code > Footer.

  • Paste the following script inside the Before tag section:

    Script (inline reference only):
    This JavaScript finds the hidden input by ID and sets its value to the current window URL:

    `document.addEventListener("DOMContentLoaded", function() {
    var urlField = document.getElementById("form-page-url");
    if (urlField) {
    urlField.value = window.location.href;
    }
    });`

  • This script runs on every page and auto-fills the hidden field with the URL if the field exists.

3. Save and Publish Your Site

  • Click Save Changes in Project Settings.
  • Publish the site to your selected domains.

4. Symbol Flexibility Maintained

  • Because you only added a hidden field and the script globally targets the same field ID, you can reuse the form as a Symbol across multiple pages without duplicating or editing code on each one.

Summary

To capture the current URL in a Webflow form symbol, add a hidden input with a unique ID, then use a site-wide script to populate that field with the page's URL. This approach preserves Symbol functionality and works across all pages without manual edits.

Rate this answer

Other Webflow Questions