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

# Salesforce

> Connect Email Meter with Salesforce to enrich your email analytics

<img style={{ borderRadius: '0.5rem' }} src="https://storage.googleapis.com/em-docs/enterprise-documentation/images/salesforce--cover.webp" />

The Salesforce integration enables you to enrich your email analytics with data from your Salesforce CRM. Each integration is custom-made to match your specific needs and use cases.

Please get in touch with your Email Meter representative to discuss the specifics of your integration and how it can be tailored to your requirements.

This integration allows you to combine your Salesforce contact, account, and opportunity data with Email Meter's email analytics, providing deeper insights into your email communications.

This integration is particularly valuable when you want to:

* Filter email analytics by Salesforce contact or account properties
* Group email statistics by account name instead of email domain
* Analyze communication patterns with different customer segments or opportunity stages

For example, you could analyze email response times specifically for contacts in the "Negotiation" stage, or see how your team's communication patterns differ between "Enterprise" and "SMB" accounts. The integration automatically syncs this data, allowing you to create more meaningful and actionable email analytics reports.

## Set up Salesforce API access

To connect Email Meter with Salesforce, you'll need to create a Connected App and generate API credentials. Follow these steps:

<Steps>
  <Step title="Create a Connected App">
    Go to your Salesforce instance, and then:

    * Click the gear icon and select `Setup`
    * In the Quick Find box, search for `App Manager`
    * Navigate to `Apps > App Manager`
    * Click `New Connected App`
    * Fill in the basic information:
      * Connected App Name: `Email Meter`
      * API Name: `Email_Meter` (auto-populated)
      * Contact Email: your email address
  </Step>

  <Step title="Configure OAuth settings">
    In the API (Enable OAuth Settings) section:

    * Check `Enable OAuth Settings`
    * Set the Callback URL to your Salesforce instance URL followed by `/services/oauth2/success`. For example:
      ```
      https://yourcompany.my.salesforce.com/services/oauth2/success
      ```
    * Select the following OAuth scopes:
      * Access and manage your data (`api`)
      * Perform requests on your behalf at any time (`refresh_token`, `offline_access`)
    * Click `Save`
    * Wait 10 minutes for the changes to take effect
  </Step>

  <Step title="Configure OAuth policies">
    After saving, you need to configure the OAuth policies:

    * Go back to `App Manager` and find the `Email Meter` app
    * Click the dropdown arrow on the right and select `Manage`
    * Click `Edit Policies`
    * Under OAuth Policies, set:
      * Permitted Users: `All users may self-authorize`
      * IP Relaxation: `Relax IP restrictions`
    * Click `Save`
  </Step>

  <Step title="Retrieve your credentials">
    After saving, you'll need to collect the following information:

    * Click `Manage Consumer Details` to view your **Consumer Key** (Client ID) and **Consumer Secret** (Client Secret)
    * You may need to verify your identity via email or authenticator app
    * Copy both values and store them securely
  </Step>

  <Step title="Generate a Refresh Token">
    To complete the integration, you need to generate a refresh token by authorizing the Connected App. In the following steps, replace `yourcompany.my.salesforce.com` with your actual Salesforce instance URL.

    1. Open a browser and visit the following URL (replace `YOUR_CONSUMER_KEY` with your actual Consumer Key):
       ```
       https://yourcompany.my.salesforce.com/services/oauth2/authorize?response_type=code&client_id=YOUR_CONSUMER_KEY&redirect_uri=https://yourcompany.my.salesforce.com/services/oauth2/success
       ```

    2. Log in with your Salesforce credentials and click **Allow** to authorize the app.

    3. After authorization, you'll be redirected to a URL like:
       ```
       https://yourcompany.my.salesforce.com/services/oauth2/success?code=AUTHORIZATION_CODE
       ```
       Copy the `code` value from the URL (everything after `code=`).

    4. Open a terminal and run the following command to exchange the authorization code for a refresh token. Replace the placeholder values with your actual credentials:

       ```bash theme={null}
       curl -X POST https://yourcompany.my.salesforce.com/services/oauth2/token \
         -d "grant_type=authorization_code" \
         -d "code=AUTHORIZATION_CODE" \
         -d "client_id=YOUR_CONSUMER_KEY" \
         -d "client_secret=YOUR_CONSUMER_SECRET" \
         -d "redirect_uri=https://yourcompany.my.salesforce.com/services/oauth2/success"
       ```

           <Tip>
             If you are not familiar with the terminal, you can use [Postman](https://www.postman.com/) to send the request instead.
           </Tip>

    5. The response will look like this:

       ```json theme={null}
       {
         "access_token": "00D2v000001XKxi...",
         "refresh_token": "5Aep861dlMxAL...",
         "signature": "MK/YGMNQhPSSnKtYicXlaU...",
         "scope": "refresh_token web api",
         "instance_url": "https://yourcompany.my.salesforce.com",
         "id": "https://login.salesforce.com/id/00D2vKxiEAG/0045Q09vAAL",
         "token_type": "Bearer",
         "issued_at": "1570030000198"
       }
       ```

       Copy the `refresh_token` value and store it securely.
  </Step>

  <Step title="Share the credentials">
    Once you have generated the credentials, please share the following with your Project Manager or Business Intelligence Consultant:

    * Consumer Key (Client ID)
    * Consumer Secret (Client Secret)
    * Refresh Token
    * Your Salesforce instance URL (e.g., `https://yourcompany.my.salesforce.com`)

    <Warning>
      Never send credentials via unencrypted email. Use a secure sharing tool like [One-Time Secret](https://onetimesecret.com/) or [Bitwarden Send](https://bitwarden.com/products/send/).
    </Warning>

    They will verify everything and configure the integration on our side.
  </Step>
</Steps>

## Frequently asked questions

<AccordionGroup>
  <Accordion title="What data is synced from Salesforce?">
    Each Salesforce integration is custom-made to match your specific needs and use cases. Common data includes Contacts, Accounts, Opportunities, and custom objects. Please get in touch with your Email Meter representative to discuss the specifics of your integration and how it can be tailored to your requirements.
  </Accordion>

  <Accordion title="What Salesforce edition do I need?">
    You need at least the Enterprise edition of Salesforce, or the Professional Edition with API access purchased as an add-on. If you're unsure about your edition, contact your Salesforce administrator.
  </Accordion>

  <Accordion title="How often is the data synchronized?">
    Data is synchronized daily by default. The sync frequency can be adjusted based on your specific needs. Please contact your Business Intelligence Consultant to discuss custom synchronization schedules.
  </Accordion>

  <Accordion title="Can I revoke access later?">
    Yes, you can revoke access at any time by deactivating or deleting the Connected App in your Salesforce settings. This will immediately stop the data synchronization.
  </Accordion>
</AccordionGroup>
