Sitecore WFFM – Add a User to a List

Posted on

Web Form For Marketers is one of the many Sitecore modules. This one specifically aims non-tech people and helps them create web forms. This module is very power-full and also inherits Sitecore legacy of being”Extensible and configurable”. We can modify form appearance, input types, validations, submit actions, etc. WFFM is regularly used to add comment section to a post, create user sign up form, feedback and contact us forms or anything of that sort. One of it’s common use is to add a person to an email subscriber list. Fair enough. Good move.  However, Sitecore Developer or Marketers seems to be getting it wrong. Here is how it must be done.


Let’s Get down to business

O’right. this is very straight forward.

  • Create the form
  • Add the contact info fields you need to the form (First Name, Last Name, Email, etc)
  • Set-up verification (optional)
  • Add “Add Contact to Contact List” save action to the submit button
  • Configure the save action and choose the list you want the persona to be in.

and we are done!?


The mistake we all make is:

We assume “Add Contact to Contact List” will get the form data and put that user in the specified list

What it actually does is:

It will add the current analytic contact form Tracker.Current.Contact property to the specified list.

This will not work because lot’s of time the user is not identified. Therefore, Analytics does not have proper contact information to send an email to. Even though this feature has been requested from Sitecore, there is no ETA on when it is going to be available. Meanwhile, there are 3 ways to make this work

  1. Only let authorized users access the form – Not ideal from a marketer perspective.
  2. Make sure the user is identified before triggering “Add Contact to Contact List” action – Requires communication with Sitecore developers and error prone
  3. Create a Custom save action that identifies the contact + add the contact to the list – What we are gonna do

You might be asking yourself why not just add the user to the list without identifying it? And the answer is: Sitecore List Managers uses Analytics contact in the variety of places and for the variety of reasons. If you find a way around it, you might never know where things might go wrong. So my advice is to leave the back door alone and stick to the front door. It’s safer that way 🙂

How to do it?

1. Create the visual Studio project and past this code to the project (or just clone the project from the repository). Build the DLL and place it in your bin folder (e.i C:\inetpub\wwwroot\hostname\Website\bin )

2. Create the patch file like the one below. You may change the value for “emialFieldName” and “firstNameFieldName” parameters according to your corresponding form’s field name.

3.  Copy the new config file to your website include folder (e.i C:\inetpub\wwwroot\hostname\Website\App_Config\Include\Wheelbarrowex)

4. Login to your Sitecore instance as admin and  navigate to /sitecore/system/Modules/Web Forms for Marketers/Settings/Actions/Save Actions

5. Right Click on “Add Contact to Contact List” action and click on Duplicate and give it a name in the pop-up message

6. Change the value for Factory Object Name to “/sitecore/wffm/actions/identifyAndAddContactToList” under Data section so the action knows where are the configuration.

7. Change the value for Display name to “Identify and Add Contact to List” under Appearance section. This will change the name in the tree so we can easily find the action later on.

Note: Appearance section is not displayed by default. Check the Standard Fields checkbox under View tab to enable it.


8. Now open form designer and assign your form a new action.

9. Select the list you wish to add contacts to.

10. Save the form

11. Smart Publish the site.

Things to consider

  • This solution has not been tested in production environment. Use it at your own risk.
  • The code could be further optimized
  • This process will add a new contact to you xDB
  • You might want to change the exception handling in the code to something perhaps more meaningfull.

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *