# Integrate with Salesforce for Advocate

## Prerequisites

Use this guide to help you set up Salesforce integration for Advocate when:

* You already have a Performance or Creator program.
* You have [cross-program tracking](https://help.impact.com/en/support/solutions/articles/48001235079-enable-cross-program-tracking) enabled between your Advocate and Performance programs, and use an existing performance conversion event shared with Advocate.
* You're adding a new Advocate program from the in-app prompt and checklist.

{% hint style="warning" %}
**Important Architectural Limitation:** The Salesforce integration is limited to connecting with only one Advocate Program ID per Salesforce instance. This one-to-one mapping is mandatory to ensure accurate data sync and program property visibility on Lead and Contact records.
{% endhint %}

{% stepper %}
{% step %}

### Connect and configure Salesforce

<details>

<summary>Initial integration setup</summary>

If you’re setting up your Salesforce integration for the first time, you must complete the following steps.

#### Enable the Salesforce integration in impact.com

This may already be set up for you if you've previously used Salesforce for your Creator or Performance program.

Start by enabling Salesforce for your impact.com account's Advocate program.

1. In impact.com, from the top navigation menu, select ![](/files/UDyrrRTGbHJFFllCZxyw) **\[User profile] →** [**Settings**](https://app.impact.com/secure/advertiser/account-settings-flow.ihtml).
2. On the left, below *Advocate Settings*, select **Integrations**.
3. On the *Salesforce* card, select **+ \[Expand]**, then select **Enable Salesforce**.
4. Select **Log in with Salesforce** and enter your Salesforce credentials.
5. Select **Allow** to give impact.com access to your Salesforce organization.

***

#### Install the impact.com package in Salesforce

{% hint style="warning" %}
**Warning:** Only Salesforce System Administrators should install and configure the impact.com package.
{% endhint %}

1. In the Salesforce AppExchange, go to the [impact.com Partner Manager page](https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000QsHhwEAF\&tab=e).
2. Select **Get It Now**.
3. Follow the on-screen instructions to install the impact.com app.

If you experience any issues installing from AppExchange, you can find a direct link to the package from the *Salesforce* card in your Advocate integration settings.

***

#### Configure your Sync settings in impact.com

1. In impact.com, from the top navigation menu, select ![](/files/UDyrrRTGbHJFFllCZxyw) **\[User profile] →** [**Settings**](https://app.impact.com/secure/advertiser/account-settings-flow.ihtml).
2. On the left, below *Advocate Settings*, select **Integrations**.
3. On the *Salesforce* card, select **+ \[Expand]** to expand the integration settings.
4. Select **Sync Settings**. Then, choose the Advocate program you want to connect and the sync frequency.
5. Only custom fields need to be set up in the sync settings. Basic lead and contact fields don't need to be mapped here.
6. Save your changes.

***

#### Configure your impact.com credentials in Salesforce

You'll need your impact.com Account SID, Auth Token, and program ID. Refer to [Edit API Access Tokens as a Brand](https://help.impact.com/en/support/solutions/articles/155000004761-edit-api-access-tokens-as-a-brand) for help finding your Account SID and Auth Token. To find your program ID in your impact.com account, select the account selection dropdown menu in the upper-left corner of the page. Your program ID is listed on the right, below the *Programs* heading.

1. In your Salesforce account, open the impact.com integration, then navigate to the Impact Setup tab.
2. Input the required fields:
   1. Impact account SID
   2. Auth token
   3. Program ID
3. Select **Save**.
4. In the *Activate Data Sync* section, toggle on the option to enable communication between Salesforce and impact.com.

***

#### Configure field mappings and event triggers in Salesforce

In this step, you'll identify which conditions in Salesforce must be met for impact.com to track a conversion event.

Alternatively, you can use Flow Builder to set up custom logic on when events should be sent to impact.com. If you plan to use Flow Builder instead, contact your impact.com-assigned Implementation Engineer or our support team for assistance.

{% hint style="success" %}
**Reversing a conversion event**: Conversion events can be reversed or modified as long as the reward is still in its pending phase or hasn't been redeemed. You will have to send through the totalPostDiscount as 0 dollars for the rewards to get retracted. Once a reward has been redeemed, the referral is considered locked and the reward can no longer be cancelled. Refer to [Batch Modifications & Reversals via FTP or Email](https://help.impact.com/en/support/solutions/articles/155000000430) for more information on the process.
{% endhint %}

***

**Field mappings**

The *Field Mappings* section is where you can specify which Salesforce fields are associated with impact.com fields to ensure accurate conversion and action reporting in impact.com.

1. In your Salesforce account, open the impact.com integration, then navigate to the **Impact Field Mapping** tab.
2. Ensure that the Salesforce field *clickId* is mapped with the impact.com field `irclickId`.
3. Some fields are mapped automatically. You can map other fields as required. If you're not sure which fields to map, reach out to your impact.com-assigned Implementation Engineer or our support team for assistance.

***

**Event triggers**

1. In Salesforce, navigate to the **Impact Event Triggers** tab.
2. In the section *Enable trigger event when a new record is created*, use the toggles to choose which events will trigger a conversion event in impact.com when a record is created in Salesforce for that object.
3. In the section *Enable trigger event when a field is changed*, use the toggles to add triggers for an event, if you want impact.com to create a conversion (and thus, create an action) when a record of the specified event is modified.
4. Exit the impact.com integration and return to your main Salesforce dashboard.

</details>
{% endstep %}

{% step %}

### Review your Microsite

Use microsites to give your customer advocates an easy way to interact with your Advocate program and start sharing.

You’ll need to:

1. [Customize the appearance of your microsite](https://help.impact.com/brand/what-would-you-like-to-learn-about/advocate-program/manage-advocate-participant-experiences/microsite-experiences/customize-microsite-layouts-and-pages).
2. Share the microsite URL with your Advocates when you launch the program.
   {% endstep %}

{% step %}

### Set up your cash rewards

Your customer advocate can be rewarded with cash payouts. Confirm that your impact.com account is [adequately funded](https://help.impact.com/en/support/solutions/articles/48001235908-deposit-funds-into-your-account).
{% endstep %}
{% endstepper %}

Congratulations! You’ve successfully navigated the technical setup. Your Advocate program is now integrated with Salesforce. To start seeing results and getting your Advocates engaged, make sure to share your unique microsite link across your marketing channels.

## Optional enhancements

<details>

<summary>Upgrade your integration</summary>

If you’re already using the [Salesforce integration](https://integrations.impact.com/impact-brand/docs/integrate-with-salesforce) for a Performance or Creator program, completing these Advocate-specific steps is entirely optional. You don’t need to make any immediate changes to your existing integration to launch your Advocate program; however, we recommend revisiting these enhancements once you’ve completed the initial setup steps above to ensure your integration is fully optimized.

Key benefits of activating the Advocate-specific integration include:

* Bi-directional data syncing
* Lead and Contact enrichment

***

#### Register referred leads

To register the referred user using Salesforce:

1. Create an [attribution flow](https://integrations.impact.com/impact-brand/docs/salesforce-flows-for-advocate).

{% hint style="warning" %}
**Important:** You must set up flows in Salesforce's Flow Builder to share data between Salesforce and your Advocate program. Data cannot be shared between the platforms without a flow.
{% endhint %}

2. [Create the *Referred by Code*](https://integrations.impact.com/impact-brand/docs/salesforce-flows-for-advocate) on your lead object.
3. Capture *Referred by Code* in your lead form.
   1. Create a *Referred By Code* hidden field in the form to capture the referral code of the referrer.
   2. Use the *Autofill* function below to retrieve the referral code from the cookie and pass it into the *Referred By Code* field.

Place the below function on your lead form. This function will break down the referral cookie and ensure the referred user is attributed in Salesforce.

{% hint style="success" %}
**Note:** This function requires the Universal Tracking Tag to be loaded for all transactions.
{% endhint %}

```javascript
<script>
  // Replace `PROGRAMID` with your Program ID.
  window.impactOnReady = function () {
    // Retrieve the DOM element you want to auto-fill the referral code into
    // There are many methods to do this but some of the most common include:
    // getElementById
    // getElementsByClassName
    // getElementsByTagName
    const element = document.getElementById("referralCodeField");
    // Make the request to retrieve referral information from the dropped cookie
    // Cookies are dropped after a user clicks on a sharelink
    impact
      .api()
      .referralCookie()
      .then(function(response) {
        // Retrieve a specific program's referral code from the response and set it on your element
        // The response returns referral codes within an object called "codes"
        // Example:
        // {
        //   "program-1": "REFERRALCODE1",
        //   "program-2": "REFERRALCODE2"
        // }
        // Use your program ID to access and apply the correct referral code to your element
        // example: element.value = response.codes["12345"];
        element.value = response.codes["PROGRAMID"];
      });
  };
</script>
```

***

#### Add Advocate fields to your layout

Adding Advocate fields to your contacts will allow you to use the contact's unique referral share link when generating promotional emails sent out of Salesforce or another Email Marketing Platform that is integrated with your Salesforce instance.

1. In Salesforce, select the **Leads** tab.
2. In the upper-right corner, select  **\[Settings]**, then **Edit Object**.
3. In the left navigation menu, select **Page Layouts**.
4. Select the layout you want to edit (e.g., Lead Layout).
5. From the layout panel at the top of the page, select and drag the **Section** field into the layout.
6. In the *Section Properties* window, enter a name (e.g., Advocate Information) and select a column style.
7. From the layout panel at the top of the page, select and drag the **Referral Code** and **Referral Link** fields into your new section.
8. Save your changes.
9. Return to the **Leads** tab and verify that the fields have been added to the layout.

You can add Advocate fields to your Contacts by following the steps above within your Contacts tab in Salesforce.

</details>

***

#### **What’s Next**

Finally, test your integration to make sure that participants are being correctly registered in impact.com and rewarded for successful referrals.

* [End-to-End Testing](https://integrations.impact.com/impact-brand/docs/end-to-end-testing-for-advocate)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://integrations.impact.com/integration-guides/for-brands/advocate/advocate-plugin-integration/integrate-with-salesforce-for-advocate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
