Web Forms for Marketers Designer

This blog post is a little bit high-level, but provides some ideas for capturing context data when filling out Web Forms for Marketers (WFFM) forms. When I say context data, I mean certain things related to the user’s current context on the website (like the User ID, or maybe even the URL of the page they are currently on when the form exists on multiple pages). Often times, this is useful information that can provide valuable insights. Here are the steps to do that.

  1. Create your form “business-as-usual”, with the fields that you need to capture from the user.
  2. Add additional single-line text fields for the context data you wish to capture. Introduce and choose a different class for these fields. See Sitecore’s documentation on how to do this.
  3. The styles for the class applied to the context data fields should hide the fields (i.e. display: none;). This simply means that the fields will be present when the form is rendered, but hidden via CSS.
  4. On the page with the form, have a rendering output JavaScript which contains the context information from the server, and that sets the hidden context data field values appropriately.

Using the strategy above, because the hidden form fields are populated when the form is submitted, you’ll have access to the data for whatever submit actions your solution uses.