Populate Episerver Insight profiles from Episerver Form fields
Apr 30, 2018
Episerver Profile store is an tool for capturing profile information and behaviours that can be visualised in Episerver Insight. Episerver Profile store can be connected to any system using standard RESTful APIs to update and add profile information for users. However there isn't currently an out the box way for users to collect user data using Episerver Forms and push this data into Episerver Profile store which can be seen in the Episerver Insight UI.
So I decided to create an add-on that would allow editors to map Episerver Form fields to Episerver Insight/Profile store fields. When using it editors set up their form as normal but also get an additional tab called "Insight profile mappings". This tab can be used to specify a property to save the form data to in the Episerver Insight profile:
Creating form and mapping to Profile store fields
Collecting form data and seeing it in Insight
Using custom fields
If a editor doesn't want to map to one of the built in fields then its possible to type in a custom field name. This will be saved in the payload section of the profile as described here: https://world.episerver.com/documentation/developer-guides/profile-store/profile-store-api/.
For developers/implementors it's also possible to get hold of the IMappedProfilePropertyNames implementation and add custom fields here:
[InitializableModule] [ModuleDependency(typeof(EPiServer.Forms.EditView.InitializationModule))] public class AddCustomPropertyInit : IInitializableModule { private Injected_mappedProfilePropertyNames; public void Initialize(InitializationEngine context) { _mappedProfilePropertyNames.Service .CustomPayloadPropertyNames.Add("CompanyReference"); _mappedProfilePropertyNames.Service .CustomPayloadPropertyNames.Add("OrganisationCode"); } public void Uninitialize(InitializationEngine context) { } }
The advantage of this approach is that the fields added will show up in the standard dropdown that editors can use when setting up their forms:
Getting it
The code is available on Github and there is also a Nuget package available over on the Episerver Nuget feed.
Configuration / install note
When installing you will require the Episerver Profile store base url and also a subscription key. Talk to Episerver managed services to get hold of these as they are not supplied by default.