Execute right to be forgotten

Version: 9.0

Use the client.ExecuteRightToBeForgotten to anonymize a contact. Executing right to be forgotten makes the following changes to a contact:

  • Deletes all identifiers - known and anonymous

  • Clears all contact facets or facet properties marked PII sensitive

    • If a facet is marked [PIISensitive], the entire facet is deleted.

    • If a facet property is marked [PIISensitive], that property is reset to its default value.

  • ConsentInformation.ExecutedRightToBeForgotten is set to true

If a conflict occurs, the operation will automatically retry. The contact is updated in memory when the operation succeeds. The following example demonstrates how to use the client.ExecuteRightToBeForgotten() method.

Note

Marketing Automation enrollments are not deleted when the right to be forgotten is executed. You can choose to manually purge the contact from all plans before you call the ExecuteRightToBeForgotten() method. For more information, see Marketing Automation Operations API.

RequestResponse
using Sitecore.XConnect;
using Sitecore.XConnect.Client;
using System;
using System.Threading.Tasks;

namespace Documentation
{
    public class ForgetContact
    {
        // Async example
        public async void ExampleAsync()
        {
            using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
            {
                try
                {
                    var reference = new Sitecore.XConnect.IdentifiedContactReference("twitter", "myrtlesitecore");

                    Task<Sitecore.XConnect.Contact> contactTask = client.GetAsync<Sitecore.XConnect.Contact>(reference, new Sitecore.XConnect.ContactExpandOptions() { });

                    Sitecore.XConnect.Contact contact = await contactTask;

                    client.ExecuteRightToBeForgotten(contact);

                    await client.SubmitAsync();
                }
                catch (XdbExecutionException ex)
                {
                    // Manage exceptions
                }
            }
        }

        public void ExampleSync()
        {
            using (Sitecore.XConnect.Client.XConnectClient client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
            {
                try
                {
                    var reference = new Sitecore.XConnect.IdentifiedContactReference("twitter", "myrtlesitecore");

                    Contact contact = client.Get<Sitecore.XConnect.Contact>(reference, new Sitecore.XConnect.ContactExpandOptions() { });

                    client.ExecuteRightToBeForgotten(contact);

                    client.Submit();
                }
                catch (XdbExecutionException ex)
                {
                    // Manage exceptions
                }
            }
        }
    }
}

Do you have some feedback for us?

If you have suggestions for improving this article,