Submit Additional Context Data with WFFM

Bhavik Patel • 5/2/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

Sitecore Technical Architect

Bhavik Patel is a certified Sitecore developer who has held Sitecore Most Valuable Professional (MVP) status since 2015. He has more than a decade of experience with enterprise-class Sitecore and Microsoft .NET framework development, including Sitecore integration with SharePoint and Business Intelligence solutions. He leads our Sitecore development practice, engineering enterprise-class Sitecore implementations for Government and commercial sector clients. He's an expert at using Sitecore Helix Framework to create re-usable architectures, streamline the integration of front-end development and provide the foundation for SEO-optimized Sitecore marketing websites.

Explore topics:

Other Blog Posts from Bhavik Patel