/// Get parameters from url var params = location.search .slice(1) .split("&") .filter(function(item) { return item.includes("="); }); /// Paramater ECID for HR referral var ecid = params.find(function(entry) { return entry.startsWith('ecid='); }) || '='; if (ecid && ecid != "=") { ecid = ecid.split('=')[1]; sessionStorage.setItem('session_ecid', ecid); } /// Cookie var decodedCookie = decodeURIComponent(document.cookie); function getHandler() { var cookieModalContent = document.getElementById('cookieModalContent'); if (cookieModalContent) { /// If cookie does not include "preference=" then the user cookie preference has not been set if(!decodedCookie.includes('preference=')) { document.body.classList.add("modal-open-cookie"); } else if (decodedCookie.includes('preference=allow')) { // If parameter is missing, try to get ecid from cookie or local storage if (!ecid || ecid == "=") { if (decodedCookie.indexOf("ecid=") != -1) ecid = decodedCookie.substring(decodedCookie.indexOf("ecid=")+5, decodedCookie.indexOf(";",decodedCookie.indexOf("ecid="))); else ecid = sessionStorage.getItem('session_ecid'); } // If ecid was successfully saved either from parameter or previous storage // it is saved in cookie sincce permisison has been granted if (ecid && ecid != "=") { var current = new Date(); var future = new Date(current.setDate(current.getDate() + 7)).toUTCString(); document.cookie = `ecid=${ecid}; expires=${future} path=/`; } setTags(true); } else if (decodedCookie.includes('preference=deny')) setTags(false); // Last resort for either scenariom, where ecid is missing, // is to retrieve the ecid from session storage if(!ecid || ecid == "=") ecid = sessionStorage.getItem('session_ecid'); } } function handleCookie(choice) { document.body.classList.remove("modal-open-cookie"); gtag('event', choice ? 'cookie_accept' : 'cookie_deny'); var current = new Date(); var future = new Date(current.setDate(current.getDate() + 7)).toUTCString(); if (choice) { document.cookie = `preference=allow; expires=${future}; path=/;`; document.cookie = `ecid=${ecid}; expires=${future}; path=/;`; } else document.cookie = `preference=deny; expires=${future}; path=/`; setTags(choice); } /// Tags usualy work with cookies, so with the response from the cookie modal we determine /// how and which tags are set. e.g. Google and FB have specific attributes whilst LinkedIn is /// either set or not. function setTags(permission) { if (permission) { // Google try { gtag('consent', 'update', { analytics_storage: 'granted', ad_storage: 'granted', }); } catch(e) {console.log(e);} // FB Tag try { fbq('consent','grant'); } catch(e) {console.log(e);} /// LinkedIn try { _linkedin_partner_id = "3959737"; window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || []; window._linkedin_data_partner_ids.push(_linkedin_partner_id); (function(l) { if (!l){window.lintrk = function(a,b){window.lintrk.q.push([a,b])}; window.lintrk.q=[]} var s = document.getElementsByTagName("script")[0]; var b = document.createElement("script"); b.type = "text/javascript"; b.async = true; b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js"; s.parentNode.insertBefore(b, s);}) (window.lintrk); } catch(e) {console.log(e);} try { // Hotjar (function(h,o,t,j,a,r){ h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; h._hjSettings={hjid:3636470,hjsv:6}; a=o.getElementsByTagName('head')[0]; r=o.createElement('script');r.async=1; r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); } catch(e) { console.log(e); } } }