dataLayer = []; dataLayer.push({"Page":{"Category":null,"Type":"Index"}}); function setFirstTimeVisit(cookieName) { function formatDate(param) { return ('0' + param).slice(-2); } function getPresentDate() { var today = new Date(); var date = today.getFullYear() + formatDate(today.getMonth() + 1) + formatDate(today.getDate()) + formatDate(today.getHours()) + formatDate(today.getMinutes()); return date; } function setCookie() { document.cookie = cookieName + '=' + getPresentDate() + ';path=/;expires=' + new Date(+new Date() + 24 * 60 * 60 * 1000 * 365); } function getCookieValues() { return document.cookie.match(RegExp('(?:^|;\\s*)' + cookieName + '=([^;]*)')); } function isCookieSet() { var match = getCookieValues(); return (match != null && match.length > 0); } if (!isCookieSet()) { setCookie(); } dataLayer.push({ 'UserFirstVisitDate': getCookieValues()[1] }) } setFirstTimeVisit('firstTimeVisit');