# How to sync Salesforce & Hubspot to deduplicate records

## How to Sync Delpha Duplicate Merges with HubSpot

After merging records in Salesforce using **Delpha Duplicate**, you might still have references to the old (merged) records in external systems like **HubSpot**. These outdated references can lead to inconsistencies across your stack.

To maintain data integrity, this guide explains how to synchronize merged record updates between **Salesforce and HubSpot**.

## Overview of Required Steps

### **In HubSpot:**

1. Set up the Salesforce-HubSpot sync and map fields between platforms.
2. Create a **Private App** in HubSpot to securely connect with Salesforce.

### **In Salesforce:**

1. Add your HubSpot **Access Token** in custom metadata.
2. Enable HubSpot-specific merge tracking in **Delpha Duplicate settings**.

## HubSpot Configuration

### 1. Enable Salesforce Sync in HubSpot

* Go to **Account Setup → Integration → Connected Apps**
* From the **Action dropdown**, click **Settings**

![Hubspot Setup](https://help.delpha.io/servlet/rtaImage?eid=ka0EY000000097p\&feoid=00N5w00000NsgBL\&refid=0EMEY000000RVwF)

* Navigate to Contact / **Contact Sync Rules** and ensure **Salesforce ↔ HubSpot sync** is activated.

### 2. Set Field Mapping Between Salesforce and HubSpot

* Go to Contact / **Contact Property Mappings** in the Connected App section.
* Add new mappings to ensure fields like `Hubspot Merged Ids` are properly linked to Salesforce objects.

| **Hubspot Property**                         | **Salesforce Field**                                       | **Sync Rule** | **Status** | **Mapping Type** |
| -------------------------------------------- | ---------------------------------------------------------- | ------------- | ---------- | ---------------- |
| <p> Record ID<br> (hs\_object\_id)      </p> | <p> DDQ Hubspot Id<br> (delpha\_\_DDQ\_HubspotId\_\_c)</p> | Two-way       | Warning    | Custom           |

### 3. Create a HubSpot Private App

* Go to **Account Setup → Private Apps**
* Click **Create Private App**
  * Name it: **Salesforce Merge**
* Click **View Access Token** and copy the generated token.

<figure><img src="https://2667079222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYmkiQxbgPV34P1O0Qsq9%2Fuploads%2FD7cmGnR8cOFKpRmxsjJh%2Fimage.png?alt=media&#x26;token=9d2aee5e-1859-46d2-a8c6-181518bed275" alt=""><figcaption><p>Hubspot Setup</p></figcaption></figure>

## Salesforce Configuration

### 1. Add the HubSpot Access Token to Custom Metadata

* Go to **Setup → Custom Metadata Types**
* Locate **Hubspot Settings** and click **Manage Records**
* Click **Edit**, then paste your **Access Token**

![Custom Metadata Type](https://help.delpha.io/servlet/rtaImage?eid=ka0EY000000097p\&feoid=00N5w00000NsgBL\&refid=0EMEY000000RVwe)

### 2. Enable HubSpot Merged IDs in Delpha

* Open the **Delpha Setup app**
* Navigate to **Duplicate Settings → Contact**
* In the **Merge Field Rules section**, activate the setting:\
  ✅ **Hubspot Merged Ids**
* Repeat the process for the **Lead** object.

<figure><img src="https://2667079222-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYmkiQxbgPV34P1O0Qsq9%2Fuploads%2F4kON2jvc3Vi2KHnrB9zR%2Fimage.png?alt=media&#x26;token=80c9a698-d35a-4b8c-9609-0e0c4b8dba59" alt=""><figcaption></figcaption></figure>

## Result

With this configuration:

* Merged Contact/Lead IDs in Salesforce will sync to HubSpot.
* HubSpot will reference the **new master record** instead of the obsolete merged one.
* Your stack stays aligned, reducing the risk of segmentation or tracking errors.

## Summary

| Platform       | Action                                                             |
| -------------- | ------------------------------------------------------------------ |
| **HubSpot**    | Enable sync, configure field mapping, create Private App           |
| **Salesforce** | Store access token in metadata, update Delpha settings for HubSpot |
