Execute right to be forgotten

Version: 10.2

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

  • In Sitecore 9.3 and later, the following additional changes are made to the contact:

    • All interactions and interaction facets are removed.

    • All calculated facets are removed.

    • The right to be forgotten operation is performed on any contact that was previously merged into the context contact. This includes making the following changes to any contact in the merge tree:

      • All interactions and interaction facets are removed.

      • All identifier anonymous identifiers are removed (a source contact might still have anonymous identifiers after a merge).

Important

In Sitecore 9.3 and later, you cannot execute the right to be forgotten in a batch with other operations. For example, you cannot set a facet and execute the right to be forgotten in a single batch.

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.

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 ContactExecutionOptions(new
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 ContactExecutionOptions(new
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,