> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cometly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce integration

> Set up the Salesforce Cometly integration to send new and updated leads, contacts and opportunities as events tied to the ads behind them.

The Salesforce Cometly integration sends new and updated leads, contacts and opportunities from your CRM to Cometly as events. An event is a conversion Cometly records for a person, such as a new lead or a closed deal.

Most of a sales pipeline happens in Salesforce, long after the ad click. With these events in Cometly you can see which ad or channel produced each lead, opportunity and closed deal, and tie CRM revenue back to ad traffic instead of measuring on-site events only.

[Salesforce Integration video](https://www.loom.com/embed/4017ef94e6a44ac18ad45af7341a9e00)

## Before you start

Check the following in Salesforce. The integration does not work without them.

* Your Salesforce edition is one of **Enterprise**, **Unlimited**, **Developer** or **Performance**.
* Your Salesforce user profile has the **Author Apex** permission enabled.
* Your validation rules allow the deployment. To deploy the integration, Salesforce runs an automated test that creates a temporary record (never saved) in your org, and your org's validation rules apply to it. If deployment fails citing a validation rule, ask your Salesforce admin to exempt the connected user from that rule (or briefly deactivate it), then click **Retry Deployment** in Cometly.

Cometly shows these requirements in an **Access required** notice when you select Salesforce in the **Create Event** dialog.

![Create Event dialog with Salesforce selected under App / Integration and the Access required notice listing the supported editions, the required permission and the validation rules.](https://mintcdn.com/cometly/alvP4_0ekdK-CBm_/images/integrations/platforms/salesforce/01.webp?fit=max\&auto=format\&n=alvP4_0ekdK-CBm_\&q=85\&s=0ada4cde58e6aed6711dd442495f48db)

## Set up the integration

**1. Connect your Salesforce account**

1. In Cometly, click **Integrations** in the sidebar.
2. Search for **Salesforce** and click **Connect** on the Salesforce card.
3. Click **Add connection** in the top right. A Salesforce sign-in window opens.
4. Log in to your Salesforce account if prompted, review the permissions and approve access.

Once complete, the connection appears under **My Connections** with your Salesforce login email and a **Connected** badge. This confirms your Salesforce connection is active.

**2. Create a Salesforce event**

1. Click **Events Manager** in the sidebar.

2. Click **Create Event**.

3. Under **App / Integration**, select **Salesforce**.

   ![Events Manager with the Create Event dialog open and three numbered markers: 1 on Events Manager in the sidebar, 2 on the Create Event button and 3 on Salesforce in the integration list.](https://mintcdn.com/cometly/alvP4_0ekdK-CBm_/images/integrations/platforms/salesforce/02.webp?fit=max\&auto=format\&n=alvP4_0ekdK-CBm_\&q=85\&s=8e6974bdaacce8acc133d815b418efac)

4. Select an event name (for example **Lead**), or click **Create New Event** to name your own, for example:

   * `NewContact`
   * `NewLead`
   * `NewOpportunity`

5. (Optional) Add an **Event description** to define what the event represents.

6. Click **Create**. The event appears in the Events Manager with the status **Draft**.

**3. Configure the Salesforce trigger**

1. On the draft event's row, click **Configure**.

2. Under **Account**, select your Salesforce connection. If you have not connected one yet, click **Connect new account**.

3. Under **Trigger**, choose one of:

   * **New Contact**
   * **Contact Update**
   * **New Lead**
   * **Lead Update**
   * **New Opportunity**
   * **Opportunity Update**

4. For an update trigger, review **Fields to watch**. The event fires when any of these fields changes. The most common standard fields are pre-selected, and you can add or remove fields, including custom fields.

5. (Optional) Under **Filters (optional)**, add conditions so that only matching records are sent, for example Opportunity stage **Equals** `Closed Won`. Use **Add condition** and **Add filter group** to build them.

6. (Optional) Under **Fields to send (optional)**, select specific fields to include. Leave it empty to send all fields.

7. Click **Continue**.

Cometly then deploys the trigger to your Salesforce org. This can take a minute or two, and the status updates automatically. If the deployment fails, the page shows the error from Salesforce and a **Retry Deployment** button.

> [!WARNING]
>
> Once selected, the Account and Trigger cannot be modified. To change the Account or Trigger, you need to create a new event.

**4. Trigger the event in Salesforce**

1. Open your Salesforce account.

2. Perform the action that matches your trigger:

   * Create or update a contact
   * Create or update a lead
   * Create or update an opportunity

3. Return to Cometly and click **Check for Data**. Recent records appear in a list.

4. Select a record and click **Continue With Selected Record**.

If no data shows up yet, click **Save & Return When Data is Ready** and come back once Salesforce has sent a record.

**5. Map fields**

1. On the **Configure Mapping** step, map the **Email** field to the email field from Salesforce. **Email** and **Event Time** are required.

2. Click **Add Field** to map any other fields passed in the record, such as name, phone or amount.

3. Click **Save & Continue**.

**6. Filter and activate the event**

1. (Optional) On the **Filtering** step, click **Add Filters** to process only some events, such as:

   * Opportunity stage equals `Closed Won`
   * Lead source equals a specific value

2. Click **Activate**.

Your Salesforce event now fires automatically when the trigger conditions are met.

> [!TIP]
>
> Create separate events for different Salesforce actions (for example `ClosedWon`, `ClosedLost`, `NewLead`) to improve attribution accuracy and reporting flexibility.

> [!NOTE]
>
> Always map the **Email** field. Email is required for identity matching and attribution inside Cometly.

## Check it worked

In **Events Manager**, the event no longer shows **Draft**. Its status is now a toggle that is switched on. Create or update a matching record in Salesforce, then open the **Events Log** tab in **Events Manager** to see the event arrive.

## Frequently asked questions

### What does Cometly install in my Salesforce org?

Cometly deploys an Apex trigger on the object you chose (Contact, Lead or Opportunity), with the Apex classes that send the record to Cometly. This is why your Salesforce user needs the **Author Apex** permission.

### Does the Salesforce integration import existing leads and opportunities?

No. The trigger runs when a record is created or updated in Salesforce after the trigger is deployed, so Cometly receives records from that point on. Leads, contacts and opportunities that already existed are sent only if a later change matches an update trigger.

### How do I stop a Salesforce event from sending data to Cometly?

Switch off the event's toggle in **Events Manager**. The data already received stays in Cometly, and Cometly removes the trigger from your Salesforce org. Switching the toggle back on deploys the trigger again, which can take a minute or two.

## Next steps

* [Check incoming events in the Events Log](https://docs.cometly.com/support/troubleshooting/general/event-log.md)
* [Learn how events work in Cometly](https://docs.cometly.com/guides/events/how-events-work.md)
* [Send conversions back to your ad platforms](https://docs.cometly.com/getting-started/send-conversions.md)
* [Send Salesforce events through Zapier instead](https://docs.cometly.com/integrations/guides/salesforce-zapier.md)

Still have questions or need a hand? We're happy to help. Reach our team at [support@cometly.com](mailto:support@cometly.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.