---
title: Setting up automatic deletion of contacts
related:
  - https://docs.kentico.com/k81/on-line-marketing-features/contact-management/working-with-contacts.md
  - https://docs.kentico.com/k81/configuring-kentico/scheduling-tasks.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **Info:** **Kentico EMS required**
>
> Features described on this page require the **Kentico EMS** license.

The contact management application generates a very large amount of data, particularly on high‑traffic websites. The system creates contacts and logs [activities](https://docs.kentico.com/k81/on-line-marketing-features/contact-management/tracking-contact-activities.md) for every visitor, which may be overwhelming for your marketers. To resolve this, you can configure the system to regularly remove contacts that meet certain conditions (and the activities logged by these contacts). This allows you to filter out inactive, outdated or otherwise unnecessary contacts without having to remove them individually.

Contact deletion is provided by a global [Scheduled task](https://docs.kentico.com/k81/configuring-kentico/scheduling-tasks.md) named **Delete inactive contacts**, which runs once per week by default. You can change the deletion interval (and other properties) by editing the task in the **Scheduled tasks** application. Click **Execute** () to run the task manually at any time.

> **Info:** The task runs in a separate thread by default and the deleting itself is done by the database server, so it should not have a negative impact on the performance of your website, even when removing a large number of contacts.

## Configuring contact deletion

When the system executes the _Delete inactive contacts_ task, it starts a deleting process for each site according to the settings in **Settings -> On‑line marketing -> Contact management -> Inactive contacts**. The task does _not delete global contacts_.

The **Delete inactive contacts** setting determines whether the contacts associated with the given site should be affected by the scheduled task. If disabled, the site's contacts can only be removed manually. Additionally, the **Enable on**\*\*‑\*\***line marketing** setting must also be enabled for every site where you wish to use automatic deletion.

The remaining settings in the section set the conditions that specify which contacts the task deletes. At least one condition must be entered in order for any contacts to be deleted. If multiple conditions are set, only those contacts that fulfill all of them will be removed. The following conditions are available:

> **Note:** **Note**: It is recommended to be very careful when configuring these conditions. Make sure that the system only deletes those contacts that are no longer necessary, otherwise you may lose valuable marketing data.

| Setting                             | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Last activity older than (days)     | Can be used to delete contacts that do not have any recent activities logged. Contacts whose latest activity is older than the specified number of days are removed.<br>For example, entering _14_ means that the task removes all contacts which do not have any activities logged within the last two weeks.                                                                                                                                                               |
| Contact created before (days)       | Can be used to clear out old contacts. All contacts that are older than the specified number of days are removed.<br>For example, setting the value to _365_ means that the task removes all contacts created more than a year ago.                                                                                                                                                                                                                                          |
| Contact last logon before (days)    | This condition is only applied to contacts that are not anonymous (i.e. only those that are associated with a specific user account). It can be used to delete contacts who have not logged into the website recently.<br>For example, entering _31_ means that the task removes all contacts who have not logged in within the last month.                                                                                                                                  |
| Contact last modified before (days) | Can be used to remove contacts that were not edited recently (e.g. had their contact address changed). Contacts whose latest modification is older than the specified number of days are deleted.<br>For example, entering _31_ means that the task removes all contacts which were not modified within the last month.                                                                                                                                                      |
| Contact merged before (days)        | Can be used to delete contacts that were merged into another contact a certain number of days ago.<br>A merged contact is one that was combined into another contact, not the contact which is the actual result of a merge operation.<br>For example, entering _7_ means that the task removes all contacts which were merged more than one week ago.                                                                                                                       |
| Merged into site contact only       | Determines whether the task should delete all contacts that were merged into another contact associated with the given site.                                                                                                                                                                                                                                                                                                                                                 |
| Merged into global contact only     | Determines whether the task should delete all contacts that were merged into a global contact.                                                                                                                                                                                                                                                                                                                                                                               |
| Contact is anonymous                | Can be used to choose whether the task should remove all contacts that are anonymous, or the opposite (those that are related to a specific user account).<br>Please note: Contacts that are only related to a customer or subscriber are still considered as anonymous.<br>The **Doesn't matter** option is the equivalent of an empty value in this condition. (i.e. if selected, the task does not delete any contacts unless at least one other condition is specified). |
| Custom SQL WHERE condition          | Allows you to enter an SQL WHERE condition that determines which contacts are deleted by the scheduled task.<br>For example:<br>_(ContactEmail is NULL OR ContactEmail = '')_<br>With this custom condition, the **Delete inactive contacts** task removes contacts that have an empty e-mail address (and fulfill all other delete conditions).                                                                                                                             |
