> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: onContactDeleted(event: ContactDeletedEvent) # Method package: wixCrmBackend # Method menu location: wixCrmBackend --> Events --> onContactDeleted # Method Link: https://dev.wix.com/docs/velo/apis/wix-crm-backend/events/on-contact-deleted.md # Method Description: An event that triggers when a contact is deleted. The `onContactDeleted()` event handler runs when a [contact](https://support.wix.com/en/article/about-your-contact-list) is deleted. The received `ContactDeletedEvent` object contains event metadata. If a contact is deleted as part of a merge, `metadata.originatedFrom` is sent as `"merge"`. Otherwise, `originatedFrom` is omitted. > **Note:** Backend events don't work when previewing your site. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## An event fired when a contact is deleted ```javascript // Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixCrm_onContactDeleted(event) { const contactId = event.metadata.entityId; console.log('Contact deleted', event); } /* Full event object: * { * "metadata": { * "id": "225bb629-4813-4c58-91ec-07aa5fbf069c", * "entityId": "ab1b7f0f-fd39-45ac-b13b-cb02c93b5e50", * "eventTime": "2021-02-10T19:18:03.442207Z", * "triggeredByAnonymizeRequest": false * } * } */ ``` ## Ignore a delete event if it originated from a merge ```javascript // Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixCrm_onContactDeleted(event) { if (event.metadata.originatedFrom === 'merge') { console.log('Contact was a source contact for a merge. Ignoring event.'); return; } else { const deletedContactId = event.metadata.entityId; console.log('Contact deleted', event); // Handle the event } } /* Full event object: * { * "metadata": { * "entityId": "c8e08afd-deac-40f7-b4c1-b42409d35df7", * "id": "1c7adeb5-c54a-4af0-8ea9-315d95cb5899", * "eventTime": "2022-02-02T22:05:47.361876Z", * "originatedFrom": "merge", * "triggeredByAnonymizeRequest": false * } * } */ ``` ---