New releases, Sitecore, xDB

Merging Visitor cookies in Sitecore CMS 7.5 and the Experience Database

Sitecore 7.5 hasn’t hit the streets yet, but as rumour has it, it will soon.

One of the highly anticipates features of Sitecore 7.5 is the ability to merge visitors across devices or cookies. This was something which had to be implemented specifically in the past, but will now be part of the platform.

How do I merge two visitors?

First of all, visitors in Sitecore 7.5 are no longer called visitors, but contacts. This is a part of a larger renaming scheme where e.g. visits (sessions) now are interactions and visitors are contacts. The renaming has consequences in the API, in that the DMS (which is now the Experience Database, xDB) API has had a major rework. Therefore expect a slightly harder upgrade path for those heavy DMS customized websites.

The key to merging contacts lies in identification. Two interactions on two different devices cannot be associated unless something common identifies them. This could be a login, an entered email address or something similar. It’s basically up to you to determine what and how to uniquely identify two contacts on two different interactions as being the same.

Sitecore.Analytics.Tracker.Current.Session.Identify(string key)

After you have determined the appropriate key to uniquely
identify a user, it’s as simple as calling the Identify method on the current interaction, ehh session? (Oops, apparently the rename hasn’t been done all consistently)

How does it work?

Using the new session handling mechanisms in Sitecore 7.5, Sitecore loads the contact associated with the current interactions cookie into session. The contact is then locked in shared session, making sure that two separate interactions will change the contact simultaneously.

  1. When calling Identify on the contact in the current interaction, any other contact identified with the same key is loaded using the LoadContactReadOnly in the ContactRepository class.
  2. The newly loaded contact is locked, making sure other interactions are not changing it.
  3. The current interaction is transferred onto the new contact, running the TransferSession pipeline
  4. MergeContacts is called, passing the current contact as “dying” and and the loaded as the “surviving”
  5. The MergeContacts pipeline is triggered, which in turn merges tags, counters, automation states, attributes and facets on the contacts.
  6. The new merged contact is now the active contact in the interaction and tracking will continue on this across multiple devices.

Things to keep in mind:

  • Sitecore 7.5 introduces new terms for the Analytics API
  • Expect a development effort when upgrading – dependant on the level of analytics use
  • In Sitecore 7.5, the platform will be able to merge visitors automatically
  • Nothing comes for free – you will have to determine how to uniquely identify contacts, and call the appropriate method
  • All steps of the actual merge is configurable using pipelines

See Nicks posts on 7.5 for a more in-depth walk through:
http://www.techphoria414.com/Blog/2014/June/Copy_of_One_Month_with_Sitecore_7-5_Part_3

Standard