# Data Collection

Before the Salesforce Interactions SDK can begin capturing data, initialize the Salesforce Interactions SDK and gain the user’s consent to track their activity.

If your site has an existing consent management platform, integrate its signals with the SDK's `init` function to confirm the user has granted permission to track.

```javascript
SalesforceInteractions.init({
  consents: [
    {
      purpose: "Tracking",
      provider: "OneTrust",
      status: "Opt In",
    },
  ],
});
```

For more information, see [Initialization](/docs/data/salesforce-interactions-sdk/guide/c360a-api-initialization.md) and [Consent](/docs/data/salesforce-interactions-sdk/guide/c360a-api-consent.md)

## Capture User Engagement Data

Once initialization is complete, you can track a user's actions by sending an interaction object within the `sendEvent()` function's payload. The `name` field of the interaction specifies the type of action that occurred.

This is the foundation for understanding user behavior, tracking conversions, and personalizing the user experience.

```javascript
// Example: Tracking when a user views a specific product.
SalesforceInteractions.sendEvent({
  interaction: {
    name: "View Catalog Object",
    catalogObject: {
      type: "Product",
      id: "65e4e737",
      attributes: {
        description: "Classic black running shoes",
      },
    },
  },
});
```

## Capture Profile Data

To identify a user or update their profile attributes, send a `user` object within the `sendEvent()` function's payload. This is essential for building a unified profile of your customer across different sessions and devices.

```javascript
SalesforceInteractions.sendEvent({
  user: {
    attributes: {
      email: "user@domain.com",
    },
  },
});
```

## Combine Profile and Engagement Data

When capturing profile data, you aren’t limited to that minimal interaction format. You can combine any of the interaction data models with profile information to collect as much context for an event as possible.

```javascript
SalesforceInteractions.sendEvent({
  interaction: {
    name: "View Catalog Object",
    catalogObject: {
      type: "Product",
      id: "65e4e737",
      attributes: {
        description: "Classic black running shoes",
      },
    },
  },
  user: {
    attributes: {
      email: "user@domain.com",
    },
  },
});
```
