In this post I will show you how you can use a WFFM custom action to identify and merge a contact and of course I will provide you with a fully documented code that you can find it in GitHub, in case you missed the previous post I recommend you to go back and check it, it will give you an overview about the problem that we are trying to overcome here.
First thing
first, A special shout-out to Jonathan Robbins for providing a great code for
identifying and merging contacts which I used here, Following are a great post by Jonathan that describe in
details the identifying and merging of contacts:
So,
Sitecore give you the ability to identify a contact when submitting a WFFM form
with the following two conditions:
- The visitor is a known user and it is logged In.
- You use “Update Contact Detail” as one of the save actions on the submit button of the form
But what if
we the contact “visitor” is not a logged in user?!
In this
case you may think of doing the following as many blogs posts advise:
- Add “Create User” save action, then
- Add “Login User” save action, then
- Add “Update Contact Details” save action
Of course,
most of the client will reject this solution!!
When searching
I found many posts that handle part of this problem, so what I did is combining
pieces together to provide a save action that will give you the ability to identify
and merge contacts.
One may ask
what is identifying and Merging contacts?
Identifying:
is the process of capturing the information that a contact may submit or
provide through his visit to the site, like email address, name or any other
information.
Merging: is
the process of matching if the current contact has been in the site before, if yes,
then lets merge this contact with the one that we already know in our xDB.
I want to
mentioned that this code can be found on GitHub and a marketplace module (complete
package of Sitecore items and code ) has been submitted and waiting for approval.
So, I will show you how to create a custom WFFM action to update contact
details (identify and merge) for logged in and non-logged in users.
Following
what you need to do:
- Duplicate the WFFM action “Update Contact Details” and name it “Custom Update Contact”.
- In the new item, Update the field “Factory Object Name” to /sitecore/wffm/actions/CustomUpdateContact
- Now, you need to use the following configuration file:
4. Now you can use the following
updated code, which is the original taken from the custom detail action:
5. Make sure to use Contact Factory created by Jonathan in the post
provided at the beginning of this post.
Complete solution can be found in GitHub, I
hope it will help.
2 comments:
Can you provide the code for Sitecore 9.0
Thanks for sharing this.,
Leanpitch provides online training in Scrum Master during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSM Certification Workshop in different cities.
csm certification cost
Post a Comment