Webflow sync, pageviews & more.
NEW

How can I pull the stored email from the first form submitted on our website and input it into a field on a later form during the sign-up process in Webflow? I have tried using the provided script but it only displays "undefined" in the field. I don't have much knowledge of JavaScript and found this script online.

TL;DR
  • Use JavaScript to store the submitted email in localStorage on the first form's submission.
  • On the later page, retrieve and auto-fill the email from localStorage into the second form's email field during page load.

You’re trying to carry a submitted email address from one Webflow form to another later in the user journey. If your current script returns “undefined,” it likely fails to correctly store or retrieve the email value. Here’s how to do it using localStorage in the browser.

1. Use JavaScript to Store Email on First Form Submit

  • Add a script in the Before tag section of your Page Settings on the first page (the form confirmation or thank-you page works too).
  • Modify this script block to match your form field's name or id:
<script>  document.addEventListener("DOMContentLoaded", function () {    var form = document.querySelector("form");    if (!form) return;    form.addEventListener("submit", function () {      var emailField = form.querySelector("input[type='email']");      if (emailField && emailField.value) {        localStorage.setItem("user_email", emailField.value);      }    });  });</script>
  • This ensures the email is saved in the browser right when the form is submitted.

2. Auto-Fill the Email on the Later Form

  • On the later page's form (during sign-up or next step), add the following in the Page Settings > Before tag:
<script>  document.addEventListener("DOMContentLoaded", function () {    var savedEmail = localStorage.getItem("user_email");    var emailField = document.querySelector("input[type='email']");    if (emailField && savedEmail) {      emailField.value = savedEmail;    }  });</script>
  • This script identifies the email field on page load and fills it with the saved value, if it exists.

3. Check Field Selectors for Accuracy

  • If your input field has a custom name or class, update querySelector("input[type='email']") to something more specific (e.g., input#signup-email or input[name='email']).
  • Use Webflow's field settings to identify the correct selector.

4. Test Across Pages

  • Submit the first form and check that your browser stores the email:
  • Open DevTools > Application > Local Storage > check for user_email.
  • Then navigate to the second form page and confirm that email is auto-filled.

Summary

Store the email in localStorage on the first form’s submission, then read and inject it in the second form during page load. Make sure your selectors are correct and that you're not testing within Webflow’s Designer Preview (localStorage only works across real page loads).

Rate this answer

Other Webflow Questions