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.

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:

You can also set the cookie domain using the setCookieDomain function.

Returns the value of the cookie domain currently used to generate the first-party cookie. The first party cookie stores the anonymousId.

Sets the value of the cookie domain used to generate the first-party cookie. The first party cookie stores the anonymousId.

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.

Returns the value of the anonymousId persisted in the first-party cookie.

Manually sets the value of the anonymousId persisted in the first-party cookie.

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.