(function ($) { // Function to get page title function getPageTitle() { return $('title').text().trim(); } // Function to get page URL function getPageURL() { return window.location.href; } if (typeof document.referrer === 'undefined' || document.referrer === null) { referer = ""; } else { referer = document.referrer; } var propertiesObj = { "pageName": getPageTitle(), "url": getPageURL(), "referer": referer }; crdl("event", "browse", propertiesObj); $(document).ready(function () { mcid = getQsParamByName("mcID"); if (mcid) { contactID = mcid.split(":")[3]; if (contactID == undefined) { for (let index = 0; index < 2; index++) { decodedMCID = decodeURIComponent(mcid); contactID = decodedMCID.split(":")[3]; if (contactID !== undefined) { break; } mcid = decodedMCID; } } if (contactID !== null && contactID !== "" && contactID !== undefined) { var auth_data = { cID: contactID }; crdl('contact', auth_data, {}); //create _cordial_mcid cookie that persists for 24 hrs setCordialCookie(contactID); } } }); function getQsParamByName(qsParam) { var vars = [], hash, qs = ""; var q = document.URL.split('?')[1]; if (q != undefined) { q = q.split('&'); for (var i = 0; i < q.length; i++) { hash = q[i].split('='); vars.push(hash[1]); vars[hash[0]] = hash[1]; } } if (vars[qsParam] !== undefined && vars[qsParam] !== null) qs = vars[qsParam]; return qs; } var setCordialCookie = function (cvalue) { var d = new Date(); d.setTime(d.getTime() + (1 * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = "_cordial_mcid=" + cvalue + ";" + expires + ";path=/"; } })(jQuery);