---
schema_version: "1"
id: 10f6f2d46632cd889e5a318dc98ee66e0fd016197850329b350910b9956bf87e
title: Integrations
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/interactions-sdk/guides/c360a-api-integration.md
canonical_url: https://developer.salesforce.com/docs/data/salesforce-interactions-sdk/guide/c360a-api-integration.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 5a7e0d2c09f3940ccf787c6a9a4a9c82a67255183178276da1ffcb7af90b938c
products:
  - Salesforce Interactions SDK
  - Data 360 Developer Documentation
---
# Integrations

The Salesforce Interactions SDK provides a set of built-in `CustomEvents` that act as integration hooks. These hooks allow developers to bind custom JavaScript listeners to specific internal lifecycle and data events within the Web SDK.

The data passed by these custom events is found within the `detail` property of the standard JavaScript `event` object passed to your listener's callback function.

Here's a full list of `CustomEvents` within the SDK.

```javascript
SalesforceInteractions.CustomEvents = {
  OnBeforeEventSend: "interactions:onBeforeEventSend",
  OnClearPersistedIdentities: "interactions:onClearPersistedIdentities",
  OnConsentRevoke: "interactions:onConsentRevoke",
  OnEventSend: "interactions:onEventSend",
  OnException: "interactions:onException",
  OnInit: "interactions:onInit",
  OnInitSitemap: "interactions:onInitSitemap",
  OnPageMatchStatusUpdated: "interactions:onPageMatchStatusUpdated",
  OnResetAnonymousId: "interactions:onResetAnonymousId",
  OnSetAnonymousId: "interactions:onSetAnonymousId",
  OnShutDown: "interactions:onShutDown",
};
```

## Custom Events Specifications

Here's a breakdown of the built-in custom events available for integration.

### OnBeforeEventSend

The `OnBeforeEventSend` event is dispatched by the SDK immediately before an event payload passed via `SalesforceInteractions.sendEvent` is processed by consuming modules.

### OnEventSend

`OnEventSend` is dispatched after an event has been successfully processed, and a request is made to the Event API (or consuming modules). This event contains the `actionEvent` payload processed in the event pipeline.

```javascript
detail: {
  actionEvent: ActionEvent;
}
```

### OnInit

`OnInIt` is dispatched when the Web SDK is successfully initialized. You can use this event for debugging Single-Page Applications (SPAs) where the SDK usually reinitializes without a page load event.

### OnInitSitemap

The `OnInitSitemap` event is dispatched whenever the Web SDK Sitemap is initialized via the `SalesforceInteractions.initSitemap()` function. This event provides confirmation that the Sitemap configuration has loaded, and contains this `detail`.

```javascript
{
    currentKey: string,
    global: GlobalConfig,
    pageTypes: PageTypeConfig[],
    settings: object
}
```

### OnPageMatchStatusUpdated

`OnPageMatchStatusUpdated` is dispatched whenever the sitemap evaluates and updates the match status of any page type defined in your sitemap configuration. Use this custom event to debug the sitemap's logic, as it shows the chronological sequence and outcome of the matching process of all page types.

The data provided in this event's `detail` is a `matchStatus` array that accumulates the status of every page type checked so far.

```javascript
detail: {
    matchStatus: PageMatchStatus[]
}
```

The `PageMatchStatus` object has this structure.

```javascript
{
  pageName: string;
  status: MatchStatus;
  startTime?: number;
  endTime?: number;
  _reject?: any;
}
```

A page type with a status of `running` includes the `startTime` of the evaluation. Conversely, when a page type evaluation concludes with a status of `matched`, `rejected`, or `selected`, the output includes the `endTime`.

Critically, the very first page type to successfully match the current URL is given the status `selected`. After a page type is selected, the sitemap stops evaluating any other remaining page types.

### OnException

This event is dispatched when a critical operation within the SDK fails, providing error information and context. Use this custom event for error logging and monitoring runtime errors.

```javascript
detail: {
    error: Error,
    context: string
}
```

The `Error` object has this structure.

```javascript
{
  stack?: string;
}
```

### OnSetAnonymousId

`OnSetAnonymousId` is dispatched every time the Web SDK assigns a new tracking identity (`anonymousId`) to the customer's device or browser, and contains this `detail`.

```javascript
{
  newAnonymousId: string;
}
```

### OnResetAnonymousId

`OnResetAnonymousId` is dispatched when `SalesforceInteractions.resetAnonymousId()` is explicitly called by your code. Use this custom event to confirm the SDK has executed the command to generate a new anonymous ID.

### OnClearPersistedIdentities

`OnClearPersistedIdentities` is dispatched when `SalesforceInteractions.clearPersistedIdentities()` is explicitly called by your code. This event confirms that known user identities (such as, `loyaltyId` or `email` used for matching) have been cleared from the SDK's internal storage.

### OnConsentRevoke

This custom event is dispatched when a user had previously granted consent, but their consent status is later updated from `Opt In` to `Opt Out`. You can use this custom event to trigger custom logic on your site when tracking is explicitly disabled after having been active.

The `OnConsentRevoke` custom event contains this `detail`.

```javascript
detail: {
    consent: Consent,
    lastUpdateTime: number,
    lastSentTime?: number
}
```

### OnShutDown

`OnShutDown` is dispatched when the Web SDK receives the signal to shut down its operations (for example, due to an `Opt Out` status update or explicit command).

## Listen for SDK Custom Events

You use the standard browser `document.addEventListener()` method to attach a function to the event's string name (prefixed with `salesforce:`), as shown in this example.

```javascript
document.addEventListener("salesforce:onEventSend", (customEvent) => {
  console.log("On Event Send: ", customEvent.detail);
});

SalesforceInteractions.sendEvent({
  interaction: {
    name: "integration_hook_test",
  },
});
```
