const SetCookie = (nDays) => { const expire = new Date(); expire.setTime((new Date()).getTime() + 3600000 * 24 * nDays); const expires = `expires=${expire.toISOString()}`; return ([cookieName, cookieValue]) => document.cookie = `${cookieName}=${encodeURIComponent(cookieValue)}; ${expires}; path=/`; } const correspondences = { 'sfmc_sub': 'SubscriberID', 'e': 'EmailAddr_', 'j': 'JobID', 'l': 'ListID', 'jb': 'BatchID', 'u': 'UrlID', 'mid': 'MemberID' }; document.location.search .substring(1) .split("&") .map(x => x.split('=')) .map(([parameterName, parameterValue]) => [correspondences[parameterName], parameterValue]) .filter(([parameterName]) => parameterName) .forEach(SetCookie(90));