remove xDB contact Sitecore 9 Sitecore How-To

Sitecore 9: Delete xDB Contact for GDPR Compliance

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

Got questions? Write us!

Contact Us

... Choose file

Daniil Raschupkin - Sitecore MVP/Lead .NET Developer

Daniil Rashchupkin

Daniil Rashchupkin

Daniil Started working with Sitecore in 2011 with version 6.0. Founded Sitecore user Group in Belarus. Certified Sitecore developer, Sitecore 9 Certified, Coveo for Sitecore Certified Developer, MCP and Sitecore MVP.

Connect via LinkedIn