Sitecore 9: Deleting xDB Contact and Complying with GDPR

Sitecore 9 has perfect documentation (https://doc.sitecore.net/developers/xp/) that answers most possible questions, but it also describes such a nice features so that it is hard not to share them.

And an example of such required for a long time functionality is conformity with PII (Personally identifiable information, https://en.wikipedia.org/wiki/Personally_identifiable_information) laws. That means now we can mark xDB contact information as ‘sensitive’ and remove it when required for GDPR Compliance. And there is no need to run MongoDB queries from console (https://sitecore.stackexchange.com/questions/7427/how-do-i-anonymize-contact-data-in-mongodb)!

First thing we need is the Sitecore.XConnect.Schema.PIISensitiveAttribute attribute. We can apply it to a Facet or its property:

      
public class SensitiveInformation : Facet
{
[PIISensitive]
public string PassportNumber { get; set; }
...
  

Second thing is a simple xConnect client method call:

      
using (XConnectClient client = GetClient())
{
    IdentifiedContactReference reference = new IdentifiedContactReference(source, identifier);

    Contact contact = client.Get<Contact>(reference, new ContactExpandOptions());

    client.ExecuteRightToBeForgotten(contact);
    client.Submit();
}
  

That’s it. xConnect will delete PII sensitive facets, reset sensitive properties values and delete all identifiers. Empty contact will stay in xDB for a data consistency.

Experience profile:

remove xDB contact Sitecore 9 profile

SQL Database:

remove xDB contact Sitecore 9 database


Do you need help with your Sitecore project?
VIEW SITECORE SERVICES