var iCookieLength = 30; // Cookie length in days var sCookieName = "aw_source"; // Name of the first party cookie to utilise for last click referrer de-duplication var sSourceParameterName = "utm_source"; // This is the name of the parameter used by your organisation that identifies the source of traffic that drove the user click. Please update this value accordingly var _getQueryStringValue = function (sParameterName) { var aQueryStringPairs = document.location.search.substring(1).split("&"); for (var i = 0; i < aQueryStringPairs.length; i++) { var aQueryStringParts = aQueryStringPairs[i].split("="); if (sParameterName.toLowerCase() == aQueryStringParts[0].toLowerCase()) { return decodeURIComponent(aQueryStringParts[1]).replace(/[^A-Z0-9]+/ig, ""); } } }; var _setCookie = function (sCookieName, sCookieContents, iCookieLength) { var dCookieExpires = new Date(); dCookieExpires.setTime(dCookieExpires.getTime() + (iCookieLength * 24 * 60 * 60 * 1000)); document.cookie = sCookieName + "=" + sCookieContents + "; expires=" + dCookieExpires.toGMTString() + "; path=/;"; }; if (_getQueryStringValue(sSourceParameterName)) { _setCookie(sCookieName, _getQueryStringValue(sSourceParameterName), iCookieLength); } if (document.cookie.indexOf("aw_source=") < 0){ _setCookie(sCookieName, "direct", iCookieLength); }