---
schema_version: "1"
id: 8f5268818bcb02b5ce4ce614d993ffe4bc7b5140d66c5d1b962ed247294e49d2
title: Identity Management
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/interactions-sdk/guides/c360a-api-identity.md
canonical_url: https://developer.salesforce.com/docs/data/salesforce-interactions-sdk/guide/c360a-api-identity.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1018d47292f7544570ff7be5a228c3882f11e7f6fb690857e2ea384abfcac32a
products:
  - Salesforce Interactions SDK
  - Data 360 Developer Documentation
---
# Identity Management

Salesforce Interactions SDK manages user tracking using a first-party cookie to assign and maintain an identity, regardless of whether the user is logged in or anonymous. The SDK identifies new and returning users with a first-party cookie named `__sfid_${domainHash}_`. The `_domainHash_` is generated by running your website’s domain through a hashing function.

This cookie stores a unique, randomly generated `anonymousId`. When a new customer visits, this ID is created for them. When they return, the SDK recognizes them using the existing `anonymousId` from the cookie, allowing for consistent tracking across sessions.

## Sharing a Cookie Across Multiple Domains

If you must share cookies across multiple domains, configure the Salesforce Interactions Web SDK with the shared domain name. This can be done through either configuration passed to `SalesforceInteractions.init` or in a function call to `SalesforceInteractions.setCookieDomain`.

For example, to share a cookie between the domains `abc.domain.com` and `xyz.domain.com`, configure the cookie domain with:

```javascript
SalesforceInteractions.init({
  cookieDomain: "domain.com",
});
```

You can also set the cookie domain using the `setCookieDomain` function.

## Identity Management Methods

### getCookieDomain()

Returns the value of the cookie domain currently used to generate the first-party cookie. The first party cookie stores the `anonymousId`.

```javascript
SalesforceInteractions.getCookieDomain();
// => "domain.com"
```

### setCookieDomain(newDomain:string): void

Sets the value of the cookie domain used to generate the first-party cookie. The first party cookie stores the `anonymousId`.

```javascript
SalesforceInteractions.setCookieDomain("domain.com");
```

**note:** Setting the cookie via the `setCookieDomain` function doesn’t take effect if the Salesforce Interactions SDK is already initialized. Ideally, this function call happens before initialization. However, you can call `SalesforceInteractions.reinit()` to force the cookie changes to take effect.

### getAnonymousId()

Returns the value of the `anonymousId` persisted in the first-party cookie.

```javascript
SalesforceInteractions.getAnonymousId();
// => "efc9953d6515dc7f"
```

### setAnonymousId(newAnonymousId:string): void

Manually sets the value of the `anonymousId` persisted in the first-party cookie.

```javascript
// Example: Setting a new ID based on a time stamp
SalesforceInteractions.setAnonymousId(`id_${Date.now()}`);
```

### resetAnonymousId()

Removes the existing first-party cookie and generates a new cookie with a newly generated, unique `anonymousId`. This effectively starts a new session for the user.

```javascript
SalesforceInteractions.resetAnonymousId();
```
