Submit Additional Context Data with WFFM

Bhavik Patel • 5/3/2017

Web Forms for Marketers Form 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.

Bhavik Patel

Bhavik is a .NET developer with over 9 years of experience, focusing on Sitecore CMS for the last 3 years. He has worked on several Sitecore CMS projects in both single-site and multi-site scenarios, and truly enjoys how extensible it is. He has a passion for problem solving and using technology to create engaging websites and applications. Bhavik is a Sitecore Technology MVP, 2015 and 2016.

Explore topics:

Other Blog Posts from Bhavik Patel



Subscribe for insights, trends and big ideas