Submit Additional Context Data with WFFM
Bhavik Patel • 5/3/2017
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.
- Create your form “business-as-usual”, with the fields that you need to capture from the user.
- 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.
- 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.
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.