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

# Salesforce Data 360

> Sync Salesforce Data 360 audiences and customer attributes to Kameleoon to target experiments and personalize experiences using unified customer profiles.

Customer profiles built in Salesforce Data 360, including audience membership and behavioral attributes, aren't visible to Kameleoon by default. Without a direct bridge between the two platforms, marketing and product teams can't use that unified customer data to target experiments or personalize on-site experiences.

Salesforce Data 360 activates segments and profile attributes to external file storage destinations, including Amazon S3 and Secure File Transfer Protocol (SFTP). Kameleoon ingests these activation files and associates the Salesforce data with the corresponding Kameleoon visitor using the `kameleoon_visitor_code`.

After synchronization, you expose Salesforce audiences and attributes as Kameleoon custom data to use them as targeting conditions in the Kameleoon Segment Builder.

<Note>
  This integration is available on demand. Contact your Customer Success Manager (CSM) for more information.
</Note>

**Use cases:**

* Target visitors belonging to a specific Salesforce audience, such as *High-value customers*.
* Target customers based on a specific attribute, such as a `customer_tier` of *Gold*.
* Personalize an experience based on behavioral data, such as `loyalty_status`, `lifetime_value_band`, or `churn_risk`.
* Combine Salesforce data natively with any other Kameleoon targeting condition.

***

## How the Salesforce Data 360 synchronization works

The integration relies on the Kameleoon visitor code acting as the common identifier across both platforms.

**The synchronization follows this continuous workflow:**

1. **Send the identifier:** Your website sends the Kameleoon visitor code to Salesforce Data 360 during the user's visit.
2. **Export the data:** Salesforce periodically publishes audience memberships and selected customer attributes to an S3 or SFTP destination.
3. **Ingest the data:** Kameleoon processes these activation files and stores the Salesforce data against the corresponding `kameleoon_visitor_code`.
4. **Target the visitor:** On the visitor’s next interaction, Kameleoon retrieves this information via custom data and evaluates it for active targeting segments.

***

## Prerequisites for the Salesforce Data 360 integration

Before you configure the integration between Kameleoon and Salesforce Data 360, verify that you meet the following requirements:

* You have a Salesforce Data 360 account with administrative permissions to configure Data Model Objects, mappings, segments, connections, and activation targets.
* You have an active Kameleoon project.
* Your Kameleoon representative has provided the specific S3 or SFTP connection credentials for your project.

***

## Step 1: Send the Kameleoon visitor code to Salesforce

To associate Salesforce profiles with Kameleoon visitors, your environment must send the Kameleoon visitor code to Salesforce Interactions.

Add the following JavaScript to your **global script** in Kameleoon. This logic ensures the script sends the visitor code to Salesforce exactly once per visit, firing only when the Salesforce object becomes available on the page:

```javascript theme={null}
// Ensure this executes only on the first page view of the current visit
if (Kameleoon.API.CurrentVisit.pageViews === 1) {
    Kameleoon.API.Core.runWhenConditionTrue(
        function () {
            // Wait for the Salesforce Interactions SDK to initialize
            return (
                typeof window.SalesforceInteractions !== "undefined" &&
                typeof window.SalesforceInteractions.sendEvent === "function"
            );
        },
        function () {
            // Transmit the Kameleoon visitor code to Salesforce
            window.SalesforceInteractions.sendEvent({
                user: {
                    attributes: {
                        eventType: "kameleoonIdentity",
                        kameleoonVisitorCode: Kameleoon.API.Visitor.code
                    }
                }
            });
        },
        500 // Polling interval in milliseconds
    );
}
```

***

## Step 2: Add and map the visitor code in Salesforce Data 360

With the visitor code flowing into your Salesforce environment, create a destination field on the Salesforce Individual Data Model Object (DMO) to store it.

### Create the field in Salesforce Data 360

1. In Salesforce Data 360, navigate to **Data Model**.
2. Open the **Individual DMO** and click **Edit**.
3. Click **Add Field** and configure it using the exact values below:

| Setting                     | Value                    |
| :-------------------------- | :----------------------- |
| **Field label**             | Kameleoon visitor code   |
| **Field API name**          | `kameleoon_visitor_code` |
| **Data type**               | Text                     |
| **Primary key**             | No                       |
| **Enable value suggestion** | No                       |

4. Click **Save** to update the DMO.

### Map the field to the Data Lake Object

Creating the DMO field does not automatically populate it. You must map the field from the incoming Data Lake Object (DLO) to your new DMO field.

1. Navigate to the relevant Data Lake Object (for example, your website DLO).
2. Map the source field containing the Kameleoon visitor identifier to `Individual.kameleoon_visitor_code`.

***

## Step 3: Configure the connection between Salesforce and Kameleoon

Kameleoon supports Salesforce Data 360 activations through either Amazon S3 or SFTP. Select and configure **one** of the following transport methods based on the credentials your Kameleoon representative provided.

<Tip>
  Kameleoon recommends using the SFTP option to set up the integration.
</Tip>

### Option A: Configure Amazon S3 for Salesforce Data 360

1. In Salesforce Data 360, navigate to **Data Cloud Setup**.
2. Under **External Integrations**, select **More Connectors** > **New**.
3. Under **Target**, select **Amazon S3**.
4. Enter a connection name (for example, *Kameleoon integration*).
5. Select **Access Key/Secret Based authentication**.
6. Enter the AWS Access Key, AWS Secret Access Key, S3 bucket, and Parent Directory provided by Kameleoon.
7. Click **Test Connection**, then click **Save**.
8. Navigate to **Activation Targets** > **New**.
9. Under **File Storage**, select **Amazon S3** and select your newly created Kameleoon connection.
10. Select **CSV** as the file format, enter a target name (for example, *Kameleoon audience sync*), and click **Save**.

### Option B: Configure SFTP for Salesforce Data 360

1. In Salesforce Data 360, navigate to **Data Cloud Setup**.
2. Under **External Integrations**, select **Other Connectors**.
3. Click **New** and select **Target** > **Secure File Transfer (SFTP)**.
4. Enter a connection name (for example, *Kameleoon integration*).
5. Enter the Kameleoon SFTP host, port, username, and Parent Directory provided by Kameleoon.
6. Enter your SSH private key and optional passphrase.
7. Click **Test Connection**, then click **Save**.
8. Navigate to **Activation Targets** > **New**.
9. Under **File Storage**, select **SFTP** and select your newly created Kameleoon connection.
10. Select **CSV** as the file format, enter a target name (for example, *Kameleoon audience sync*), and click **Save**.

***

## Step 4: Activate Salesforce audiences and attributes to Kameleoon

With the connection established, select the specific Salesforce Data 360 segments and attributes to push to Kameleoon.

1. In Salesforce Data 360, navigate to **Segments**.
2. Select the segment you want to synchronize with Kameleoon.
3. In the **Activations** tab, click **New** and select your Kameleoon Audience Sync target.
4. Select **Individual** as the Activation Membership object.
5. Click **Add Attributes**, expand the **Individual** entity, and add `kameleoon_visitor_code`.
6. Add any additional Salesforce attributes you want to use for targeting in Kameleoon (for example, `customer_tier` or `churn_risk`).

<Warning>
  The `kameleoon_visitor_code` attribute is mandatory. Without it, Kameleoon cannot map the data to the correct visitor profile.
</Warning>

<Note>
  When configuring the activation refresh type in Salesforce, select **Incremental**, which ensures audience memberships and attributes synchronize efficiently by updating only the changed records, rather than transferring the entire audience on every run.
</Note>

***

## Step 5: Retrieve Salesforce data in your global script

To make the synced Salesforce data available for targeting, retrieve it from the Kameleoon remote data store and register it as custom data using the JavaScript Activation API.

Add this code to the same global script that sends the visitor code to Salesforce, not to a custom data's own retrieval code. The retrieval call is asynchronous and requires a callback, so calling it once here lets you register every attribute and audience from a single server response instead of triggering a separate remote lookup for each one:

```javascript theme={null}
// Ensure this executes only on the first page view of the current visit
if (Kameleoon.API.CurrentVisit.pageViews === 1) {
    Kameleoon.API.Data.retrieveDataFromRemoteSource(
        Kameleoon.API.Visitor.code,
        function (data) {
            // Register each synced Salesforce audience membership
            if (Array.isArray(data.salesforce_audiences)) {
                data.salesforce_audiences.forEach(function (audience) {
                    Kameleoon.API.Data.setCustomData("Salesforce Audiences", audience);
                });
            }

            // Register the synced Salesforce Customer Tier attribute
            if (data.customer_tier) {
                Kameleoon.API.Data.setCustomData("Salesforce Customer Tier", data.customer_tier);
            }
        }
    );
}
```

View the [Activation API reference](../../../../developer-docs/apis/activation-api-js/api-reference/api-reference#retrievedatafromremotesource) for full documentation on `retrieveDataFromRemoteSource()` and [`setCustomData()`](../../../../developer-docs/apis/activation-api-js/api-reference/api-reference#setcustomdata).

### Retrieve Salesforce data for Feature Experimentation

If you target visitors with Kameleoon Feature Experimentation instead of web experimentation, no global script runs in the browser. Retrieve the data with a Kameleoon SDK instead, using `getRemoteData()` to fetch the payload and `addData()` to register each value before you evaluate a feature flag:

```javascript theme={null}
import { KameleoonClient, CustomData } from '@kameleoon/javascript-sdk';

const client = new KameleoonClient({ siteCode: 'my_site_code' });

async function init() {
    await client.initialize();

    // Get the visitor code
    const visitorCode = client.getVisitorCode();

    // Fetch the synced Salesforce payload for this visitor
    const jsonData = await client.getRemoteData(visitorCode);
    const data = JSON.parse(jsonData);

    // Register the synced Salesforce audience memberships in a single call.
    // Repeated addData() calls with the same custom data name replace the
    // previous value instead of appending, so pass every audience as a
    // variadic argument to one CustomData instance.
    if (Array.isArray(data.salesforce_audiences) && data.salesforce_audiences.length > 0) {
        client.addData(visitorCode, new CustomData('Salesforce Audiences', ...data.salesforce_audiences));
    }

    // Register the synced Salesforce Customer Tier attribute
    if (data.customer_tier) {
        client.addData(visitorCode, new CustomData('Salesforce Customer Tier', data.customer_tier));
    }

    // Evaluate the feature flag using the data you just added
    const isActive = client.isFeatureFlagActive(visitorCode, 'my_feature_key');
}

init();
```

View the [JavaScript SDK documentation](../../../../developer-docs/sdks/web-sdks/js-sdk) for full documentation on `getRemoteData()`, `addData()`, and `isFeatureFlagActive()`. For the complete Feature Experimentation workflow, view [Use external data to target users](../../../../developer-docs/feature-experimentation/targeting-and-segmentation/use-external-data-to-target-users).

***

## Step 6: Create custom data in Kameleoon

Kameleoon automatically processes the incoming Salesforce CSV activation files. To use this data for targeting, create **custom data** objects in the Kameleoon platform that match the values your script sets.

Navigate to **Settings > Custom data > New custom data** and configure the objects based on your required data types.

For more information on Kameleoon custom data, view [Create custom data](../../../assets/custom-data/create-custom-data).

### Example 1: Map Salesforce audiences (list data)

To target visitors based on their presence in multiple Salesforce audiences, configure the custom data with the following settings:

* **Name:** Salesforce Audiences
* **Retrieval method:** Kameleoon Activation API
* **Type:** List
* **Format:** String
* **Scope:** Visit

### Example 2: Map Salesforce profile attributes (string data)

To target visitors based on a specific, singular profile attribute, such as a customer tier, create a separate custom data entry with the following settings:

* **Name:** Salesforce Customer Tier
* **Retrieval method:** Kameleoon Activation API
* **Type:** Single
* **Format:** String
* **Scope:** Visitor

<Note>
  If you target visitors with Kameleoon Feature Experimentation, select **Kameleoon SDK method** as the retrieval method for both custom data entries instead of **Kameleoon Activation API**.
</Note>

***

## Step 7: Target Salesforce audiences in Kameleoon

After you map the custom data, the Salesforce information becomes natively available within the Kameleoon Segment Builder.

**To use the data in a segment:**

1. Navigate to the **Segment Builder** (**Settings** > **Segments** > **New segment**).
2. Drag your newly created custom data condition into the segment rule.
3. Configure the logic operator. For example, to target high-value customers, configure:

   * `Salesforce Audiences` **is among** `High-value customers`

You can combine these natively with other Kameleoon criteria to create highly specific segments (for example, *Salesforce Customer Tier = Gold* **AND** *Device = Mobile*).

For more information on creating segments, view [Create a segment](../../../assets/segments/create-a-segment).

***

## Considerations for the Salesforce Data 360 integration

Factor in the following system behaviors when maintaining the integration between Salesforce Data 360 and Kameleoon:

* **Identifier consistency:** The `kameleoon_visitor_code` string that Salesforce exports must exactly match the visitor's cookie string in Kameleoon. If the identifier is altered or hashed during the Salesforce import process, the sync fails.
* **Data freshness:** The integration relies on asynchronous file drops. Changes to a user's profile become available in Kameleoon only after the Salesforce segment refreshes, Salesforce delivers the CSV activation file, and Kameleoon ingests the resulting payload.
* **Data privacy:** Activate only the specific attributes required for experimentation or personalization. Avoid activating personally identifiable information (PII) when a broader categorical attribute (such as a generic `LTV_band`) achieves the same targeting goal.
