- [Home page](https://www.brimit.com/)
- [Blog](https://www.brimit.com/blog)

# Sitecore 9: Deleting xDB Contact and Complying with GDPR

[#How-to](https://www.brimit.com/blog?categories=#How-to) [DXP](https://www.brimit.com/blog?platforms=DXP)
[Daniil Raschupkin](https://www.brimit.com/blog/author?authors=Daniil%20Raschupkin) on November 9, 2017

Sitecore 9 has perfect documentation ([https://doc.sitecore.net/developers/xp/](https://doc.sitecore.net/developers/xp/ "Sitecore 9 documentation")) 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](https://en.wikipedia.org/wiki/Personally_identifiable_information "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](https://sitecore.stackexchange.com/questions/7427/how-do-i-anonymize-contact-data-in-mongodb "MongoDB queries"))!

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 ](https://www.brimit.com/-/media/images/blog/sc91.png?la=en&hash=A55C6A8E76B98FE95700C74AFB0744DB)

SQL Database:

![remove xDB contact Sitecore 9 database](https://www.brimit.com/-/media/images/blog/sc92.png?la=en&hash=45C3C2EBF483FC7E1A6968B26B464635)

##### Do you need help with your Sitecore project?

      ![](https://www.brimit.com/blog/~/media/CD37043DFD1F491D8E92958A11959F75.ashx?la=en&hash=D08B252DD3B41C09B588007541E5D22F)

   [VIEW SITECORE SERVICES](https://www.brimit.com/expertise/sitecore-cms)

###### Author

![daniil_side2](https://www.brimit.com/-/jssmedia/feature/blogs/authors/daniil_side2.jpg?h=180&iar=0&w=360&hash=B759563CA3F35642FD513A79358CC84C)

Daniil Raschupkin

Sitecore Solution Architect
[Daniil Raschupkin](https://www.brimit.com/blog/author?authors=Daniil%20Raschupkin)

###### More By Categories

[#Events](https://www.brimit.com/blog?categories=#Events) [#How-to](https://www.brimit.com/blog?categories=#How-to) [#News](https://www.brimit.com/blog?categories=#News) [#Guides](https://www.brimit.com/blog?categories=#Guides)

###### More by Platform

[Data and AI](https://www.brimit.com/blog?platforms=Data%20and%20AI) [DXP](https://www.brimit.com/blog?platforms=DXP) [E-commerce](https://www.brimit.com/blog?platforms=E-commerce) [Internet of Things](https://www.brimit.com/blog?platforms=Internet%20of%20Things) [Sales and marketing automation](https://www.brimit.com/blog?platforms=Sales%20and%20marketing%20automation)
