> For the complete documentation index, see [llms.txt](https://docs.chord.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chord.co/activate/event-streaming/destinations/email-and-marketing/salesforce-marketing-cloud.md).

# Salesforce Marketing Cloud

**Salesforce Marketing Cloud (SFMC) Collect.js**, also called Web Collect or Collect Tracking Code, is a browser JavaScript library from Salesforce Marketing Cloud Engagement. It captures website visitor behavior, such as page views, product interactions, cart activity and purchases. It delivers that data to SFMC for use in Einstein Recommendations, Journey Builder entry sources, and web and email attribution.

This destination loads the Collect.js script in the browser and maps Chord events to the matching Collect.js tracking calls. All data flows directly from the visitor's browser to Salesforce's `collect.igodigital.com` endpoints.

{% hint style="info" %}
Collect.js is part of Marketing Cloud Personalization (formerly Personalization Builder and Einstein Recommendations). Configure it in SFMC **before** you install it on your site. Go to **Email or Web Recommendations > Personalization Builder > Collect** to finish setup. The `collect.igodigital.com` endpoint does not resolve until you do.
{% endhint %}

## Getting started

Before adding this destination, complete the Collect setup inside SFMC:

1. Log into Marketing Cloud Engagement.
2. Go to **Email Recommendations** or **Web Recommendations**.
3. Under **Personalization Builder**, select **Collect** and complete the setup wizard.
4. Note your **Member ID (MID)**, found in **Setup > Account Settings**.

## Settings

* **Destination Name** (required): a name to tell this destination apart.
* **Marketing Cloud Member ID (MID)** (required): your Salesforce Marketing Cloud Member ID, found in **Setup > Account Settings**. Chord uses it to load the Collect.js script from `https://<MID>.collect.igodigital.com/collect.js` and identify your org.
* **Consent Requirements** (optional): the consent categories a visitor must accept before Chord sends data to this destination. See [Consent](/activate/event-streaming/consent.md).

## Connect

Add **Salesforce Marketing Cloud Collect.js** from the destination catalog, using the settings above. See [Connect a destination](/activate/event-streaming/connect-a-destination.md) for the full steps.

## Identity

On every event, if a user email or userId is available, the destination calls `setUserInfo` to tie the visitor to the Collect.js cookie. This lightweight per-event stamp contains only `email`:

```js
_etmc.push(["setUserInfo", { "email": "lisa@example.com" }])
```

Chord takes the email from `properties.email`, then `context.traits.email`, then `traits.email`. If there is no email, it uses the `userId`. If neither is present, `setUserInfo` is skipped for that event.

On `identify()` calls, **the event's `traits` are additionally passed as contact attribute details** for affinity seeding. Trait labels that match catalog field names (for example `gender`, `age_group`) boost the contact's affinity for products whose catalog field has that value. The `identify` handler also fires `trackPageView`, which Collect.js requires for affinity updates to register.

```js
// Example identify() call
chord.identify("user-123", {
  email: "lisa@example.com",
  gender: "female"
})

// Results in:
_etmc.push(["setUserInfo", {
  "email": "lisa@example.com",
  "details": { "id": "user-123", "gender": "female" }
}])
_etmc.push(["trackPageView"])
```

Reserved trait keys (`email`, `userId`, `anonymousId`, `createdAt`) are excluded from `details`. All other traits are included as strings. Chord adds the `userId` as `details.id`.

## Event mapping

| Chord event                                                                             | Marketing Cloud event           | Notes                                          |
| --------------------------------------------------------------------------------------- | ------------------------------- | ---------------------------------------------- |
| `page`                                                                                  | `trackPageView`                 | `{ category }` if available                    |
| `identify`                                                                              | `setUserInfo` + `trackPageView` | Full traits in `details`                       |
| [`Product Viewed`](/collect-data/tracking-plan/product-viewed.md)                       | `trackPageView`                 | `{ item: sku }`                                |
| [`Product List Viewed`](/collect-data/tracking-plan/product-list-viewed.md)             | `trackPageView`                 | `{ category }` if available                    |
| [`Products Searched`](/collect-data/tracking-plan/products-searched.md)                 | `trackPageView`                 | `{ search: query }`                            |
| [`Product Added`](/collect-data/tracking-plan/product-added.md)                         | `trackCart`                     | Single added item                              |
| [`Cart Viewed`](/collect-data/tracking-plan/cart-viewed.md)                             | `trackCart`                     | Full cart snapshot                             |
| [`Checkout Started`](/collect-data/tracking-plan/checkout-started.md)                   | `trackCart`                     | Full cart snapshot                             |
| [`Order Completed`](/collect-data/tracking-plan/order-completed.md)                     | `trackConversion`               | `cart`, `order_number`, `discount`, `shipping` |
| `Wishlist Updated`                                                                      | `trackWishlist`                 | Full wishlist replacement                      |
| [`Product Added to Wishlist`](/collect-data/tracking-plan/product-added-to-wishlist.md) | `trackWishlist`                 | Full wishlist replacement                      |

All other `track` events are silently ignored. Collect.js has no generic event method.

## Page views

A plain `page()` call fires `trackPageView`. If a category is available it is included. The category is resolved in this order: `properties.page_category_name` → `properties.category` → `context.page.category`.

```js
_etmc.push(["trackPageView", { "category": "Tennis Shoes" }])
```

A page with no category fires a bare `trackPageView` with no arguments.

## `Product Viewed` events

The `item` parameter must match the **ProductCode catalog field** in SFMC. If it doesn't match a catalog record, no affinity is built.

```js
_etmc.push(["trackPageView", { "item": "SKU-12345" }])
```

The item code is resolved in this order: `properties.sku` → `properties.product_id` → `properties.productId` → `properties.id`. If none is present, Chord sends a bare `trackPageView`.

## `Product List Viewed` events

Category list pages pass the category name from `properties.category`:

```js
_etmc.push(["trackPageView", { "category": "Shoes" }])
```

## `Products Searched` events

Search results pass the search term. The term is resolved from `properties.query` → `properties.search_term` → `properties.search_keyword`.

```js
_etmc.push(["trackPageView", { "search": "blue running shoes" }])
```

## Cart tracking

`trackCart` sends the current cart state. Collect.js **overwrites** the stored cart on every call, so send all active items each time.

For `Product Added`, only the single added product is sent (Collect.js has no additive cart API). For `Cart Viewed` and `Checkout Started`, the full product array from the event is sent.

Cart item fields (`item` and `unique_id` are required; `quantity` and `price` are included when present):

| Chord source (priority order)        | Marketing Cloud field | Notes                                                                         |
| ------------------------------------ | --------------------- | ----------------------------------------------------------------------------- |
| `sku` → `product_id` → `id` → `name` | `item`                | Must match ProductCode catalog field                                          |
| `sku` → `product_id` → `id`          | `unique_id`           | Child/variant identifier                                                      |
| `quantity`                           | `quantity`            | Included as a string. Defaults to `1` for products Chord reads from the event |
| `price`                              | `price`               | Included as a string when present                                             |

## `Order Completed` events

`trackConversion` records the purchase.

```js
_etmc.push(["trackConversion", {
  "cart": [{ "item": "SKU-001", "unique_id": "SKU-001", "price": "29.99", "quantity": "2" }],
  "order_number": "ORDER-1234",
  "discount": "10",
  "shipping": "5.99"
}])
```

| Chord source (priority order)                                                                                                                                                                             | Marketing Cloud field | Notes |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ----- |
| Product array mapped through cart item fields (see above). Chord sends the call even if the order has no products                                                                                         | `cart`                |       |
| `properties.order_id` → `properties.orderId` → `properties.id`. If none of these is present, Chord uses the cart ID (`properties.cart_id` or `properties.cartId`). An order ID always wins over a cart ID | `order_number`        |       |
| `properties.discount` (omitted if not present)                                                                                                                                                            | `discount`            |       |
| `properties.shipping` (omitted if not present)                                                                                                                                                            | `shipping`            |       |

## Wishlist

`Wishlist Updated` and `Product Added to Wishlist` events map to `trackWishlist`. Each call **replaces** the full wishlist, so include all items on every call.

Both `items` and `skus` arrays are populated from the same field resolution: `sku` → `product_id` → `id` for each product. A `Product Added to Wishlist` event carries one product, so that product is the whole list Chord sends.

## Initialization

`setOrgId` is pushed to the `_etmc` queue before the Collect.js script loads, so the script picks it up from the queue on initialization. The script is loaded once per page session, and later events reuse the loaded instance.

Initialization fails gracefully if the MID is missing or the script fails to load. All later events for that session are silently skipped.

## Consent

Visitor consent is covered in [Consent](/activate/event-streaming/consent.md). To limit which events this destination receives, set the connection's **Events Allowlist**. See [Connect a destination](/activate/event-streaming/connect-a-destination.md).

## CSP requirements

If your site uses a Content Security Policy, add the following to permit Collect.js to load and send data:

```
script-src https://<MID>.collect.igodigital.com
connect-src https://<MID>.collect.igodigital.com
img-src https://<MID>.collect.igodigital.com
```

Replace `<MID>` with your numeric Marketing Cloud Member ID.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.chord.co/activate/event-streaming/destinations/email-and-marketing/salesforce-marketing-cloud.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
