Episerver Forms: Adding Datasource for hidden field with Profile Store data

blog header image

Some times, it can be handy to track additional data about the visitor along with a form submission. If you have Profile Store, stuff like DeviceId, sessionId and maybe even the ProfileId can definitely come in handy later when you are later processing the form submissions. Here is a code sample on how to do that.


Want to get more out of Episerver Forms?

We are experts in optimizing and extending Episerver forms. Reach out and let's talk.

Reach Out

Luckily, Episerver Forms are really easy to extend. And in the case of adding hidden fields with visitor data, we won't even have to create a new form element. It already exist, aptly named "Hidden Visitor Profiling". This is an element type that basically let's you take some data and add it as a hidden form submission field. The data comes from a collection of IVisitorDataSources, so to add more data, all we have to do is to add a new DataSource (+ the appropiate language translation texts).

The Episerver profile store is a powerful tool - and a typical customization you need to do is to ensure that a Form actor tracks the form postings in the profile store. However - what if something goes wrong in the tracking process and this ends up meaning a lost lead? We can't have that - so as a safety precaution it can be a good idea to track key fields like the DeviceId from profile store (coming from the "_madid" cookie, or maybe even the ProfileId - although you should be aware that it can change if the profile gets 'merged' (or mutilated, nuff said).

The code below does just that - but be aware that in order to get the ProfileId, it uses a coming ProfileStoreSDK which isn't publicly available yet - so for now, you might want to comment out the code refering to ProfileId.

Recent posts