< Webflow

Include Logged In User's Email on Form Submissions

Include the logged-in user's email and Cotter User ID to your Webflow Forms.

Here's how you can include the logged-in user's email and Cotter User ID to a form in Webflow:

  1. Make sure you have followed our Webflow + Cotter tutorial and added a Protected Page (Feature 1)


  3. Add a Form to your Protected Page --> set the id =user-data-form-a.



  5. Add this code to the Body of the Protected Page:

 window.onload=function() {
  var cotter = new Cotter("<YOUR API KEY ID>"); // 👈 Specify your API KEY ID here
  var user = cotter.getLoggedInUser()
  var userEmailField = document.createElement("input");
  userEmailField.setAttribute("type", "hidden");
  userEmailField.setAttribute("name", "email");
  userEmailField.setAttribute("value", user?.identifier);
  var userIDField = document.createElement("input");
  userIDField.setAttribute("type", "hidden");
  userIDField.setAttribute("name", "cotter_user_id");
  userIDField.setAttribute("value", user?.ID);
  // 👈 Append this to each form element that you want with the form's id

(If you have more than 1 form, you can copy the code above and replace user-data-form-a with your Form's id).

☁️Made with Typedream