1
votes

I have been using Sitecore for a couple of years, and now looking to begin utilizing the Experience functionality found in Sitecore 8.

I have a view that will capture some user-provided data. How do I go about creating a "person" (don't know the correct Sitecore terminology) in the Analytics database from custom code.

2

2 Answers

6
votes

You'll need to create a Contact. Contacts are a kind of profile store for xDb and allows you to store data about your visitors. A contact has a built in list of facets (email, phone number, name etc) that make up the contact record, but it's also possible to create your own facets.

If you are building a form to capture data you can use the new Tracker api to identify and update facets on a contact.

Here's some code to do this:

https://github.com/ianjohngraham/CoreBlimey.Utils/blob/master/CoreBlimey.Utils/xDB%20Contact%20Creator/CreateContact.aspx.cs

There's a walk through of how the code fits together here:

https://m.youtube.com/watch?v=Jq6TpMgUGAk

(Apologies for the sound quality)

Also if you are using the WFFM module in Sitecore 8 there are some new save actions that will create contacts and store xDB data.

1
votes

You may want to spend time on the docs. Please refer here for articles and guides related to Personalization and Personas.

Most of the configuration can be specified in Experience Analytics within Sitecore and you can leverage Rules Engine to perform actions.