The Personalization module of the Salesforce Interactions SDK sets the following two cookies.
A cookie prefixed with _evga_ that stores Personalization Identities such as the anonymousId or any persisted ID.
A cookie prefixed with _sfid_ that stores any consents and their status provided to the Web SDK.
How to get the _evga_ cookies?
function getEVGACookies() {
// Get all cookies as a single string
const allCookies = document.cookie;
// Split the string into individual cookies
const cookieArray = allCookies.split('; ');
// Filter cookies that contain '_evga_'
const evgaCookies = cookieArray.filter(cookie => cookie.includes('_evga_'));
// Create an object to store cookie names and values
const evgaCookieObj = {};
// Loop through the filtered cookies and store them in the object
evgaCookies.forEach(cookie => {
const [name, value] = cookie.split('=');
evgaCookieObj[name] = decodeURIComponent(value);
});
return evgaCookieObj;
}
// Usage
const cookies = getEVGACookies();
console.log(cookies);
How to get the _sfid_ cookies?
function getSFIDCookies() {
// Get all cookies as a single string
const allCookies = document.cookie;
// Split the string into individual cookies
const cookieArray = allCookies.split('; ');
// Filter cookies that contain '_sfid_'
const evgaCookies = cookieArray.filter(cookie => cookie.includes('_sfid_'));
// Create an object to store cookie names and values
const evgaCookieObj = {};
// Loop through the filtered cookies and store them in the object
evgaCookies.forEach(cookie => {
const [name, value] = cookie.split('=');
evgaCookieObj[name] = decodeURIComponent(value);
});
return evgaCookieObj;
}
// Usage
const cookies = getSFIDCookies();
console.log(cookies); //You need to decodeURIComponent