var _serviceDomain = "//et.educationdynamics.com"; var _commandsHashTable = {}; _commandsHashTable['_etPageView'] = etPageView; _commandsHashTable['_etEvent'] = etEvent; _commandsHashTable['_etImpression'] = etImpression; var _pageViewGUID; var _enterpriseGUID; //include the JSON file if the browser does not support the JSON object natively (function(){ if (!window.JSON){ var script = document.createElement('script'); script.type = "text/javascript"; script.language = "javascript"; script.src = _serviceDomain+ "/json2.js"; document.body.appendChild(script); } }); var _etQueue = function () { this._flushed = false; this._methods = []; }; _etQueue.prototype = { push: function (method) { if (this._flushed) { _commandsHashTable[method.slice(0, 1)](method.slice(1)); } else { this._methods.push(method); } }, flush: function () { if (this._flushed) { return; } else { while (this._methods[0]) { var method = this._methods.shift(); _commandsHashTable[method.slice(0, 1)](method.slice(1)); } this._flushed = true; } } }; (function() { SetTrackingPixel(); })(); function CompleteTracking(enterpriseGUID) { _enterpriseGUID = enterpriseGUID; CheckForCampaignTracking(); _etq = toQueue(_etq); _etq.flush(); }; function CreateDynamicScript(source) { var et = document.createElement("script"); et.async = true; et.src = source; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(et, s); } function SetTrackingPixel() { //var source = _serviceDomain + "/PixelTrack_ET.aspx"; var source = _serviceDomain + "/Tracking/FirePixelTrackET"; CreateDynamicScript(source); }; function CheckForCampaignTracking() { var trackid = GetQueryStringParam('trackid'); var cookieChecked = false; if (!trackid) { trackid = GetCookie("_CampaignTrackID"); cookieChecked = true; } var affid = GetQueryStringParam('aid'); if (affid) { CreateSessionCookie("_AffiliateID", affid) } if (trackid) { if (!cookieChecked) { CreateSessionCookie("_CampaignTrackID", trackid); } } }; function GetQueryStringParam(name){ var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href); if (!results) { return 0; } return results[1] || 0; }; function toQueue(array) { var _newQueue = new _etQueue(); while (array[0]) { if (array[0] !== undefined) _newQueue.push(array.shift()); } return _newQueue; }; function etPageView(args) { //var prepopDeviceGUID = args[0]; if (!_pageViewGUID) { _pageViewGUID = CallGetUUID(); } var guids = VerifyCookies(true); if (!guids.newCookieCreated) { var url = window.location.href; var pageDataLayer = ""; if(typeof dataLayer !== 'undefined' && dataLayer && dataLayer[0]) pageDataLayer = JSON.stringify(dataLayer[0]); var source = _serviceDomain + "/Tracking/InsertPageView?pageViewGUID=" + encodeURI(_pageViewGUID) + "&sessionGUID=" + encodeURI(guids.sessionGUID) + "&fullURL=" + encodeURIComponent(url)+ "&dataLayer=" + encodeURIComponent(pageDataLayer); //if (pageViewCategory) { // source += "&pageViewCategory=" + encodeURI(pageViewCategory); //} CreateDynamicScript(source); } //var allClickTracs = document.querySelectorAll('[data-clickTrack]'); //[].forEach.call(allClickTracs, function(item) { // item.href = item.href.replace("pageViewGUID=","pageViewGUID=" + _pageViewGUID); //}); }; function etEvent(args) { var actionName = args[0]; var actionValue = args[1]; var actionCategory = args[2]; var href = args[3]; if (!_pageViewGUID) { _pageViewGUID = CallGetUUID(); } var guids = VerifyCookies(false); var source = _serviceDomain + "/Tracking/InsertEventAction?pageViewGUID=" + encodeURI(_pageViewGUID) + "&actionName=" + encodeURI(actionName) + "&actionValue=" + encodeURI(actionValue); if (actionCategory) { source += "&actionCategory=" + encodeURI(actionCategory); } CreateDynamicScript(source); if (href) { setTimeout("gotoUrl('" + href + "')", 100); } }; function gotoUrl(href) { window.location.href = href; }; //function VerifyCookies(includePageView, prepopDeviceGUID) { function VerifyCookies(includePageView) { var sessionGUID = GetCookie("_Session"); var deviceGUID = GetCookie("_Device"); var cookieCreated = false; if (!sessionGUID) { sessionGUID = CreateSessionCookie("_Session", CallGetUUID()); cookieCreated = true; } if (!deviceGUID) { //if (!prepopDeviceGUID) // deviceGUID = CreateDeviceCookie("_Device", CallGetUUID()); //else deviceGUID = CreateDeviceCookie("_Device", CallGetUUID()); cookieCreated = true; } if (cookieCreated) { SaveCookies(sessionGUID, deviceGUID, includePageView); } return { sessionGUID: sessionGUID, deviceGUID: deviceGUID, newCookieCreated: cookieCreated }; }; function SaveCookies(sessionGUID, deviceGUID, includePageView) { var url = window.location.href; var referUrl = document.referrer; var campaignTrackId = GetCookie("_CampaignTrackID"); var source = _serviceDomain + "/Tracking/SaveAllGUIDs?sessionGUID=" + encodeURI(sessionGUID) + "&deviceGUID=" + encodeURI(deviceGUID) + "&referringURL=" + encodeURIComponent(referUrl); if(_enterpriseGUID) { source += "&enterpriseGUID=" + encodeURI(_enterpriseGUID); } if(campaignTrackId) { source += "&campaignTrackId=" + encodeURI(campaignTrackId); } if (includePageView) { var pageDataLayer = "";; if(typeof dataLayer !== 'undefined' && dataLayer && dataLayer[0]) pageDataLayer = JSON.stringify(dataLayer[0]); source += "&pageViewGUID=" + encodeURI(_pageViewGUID) + "&pageViewURL=" + encodeURIComponent(url) + "&dataLayer=" + encodeURIComponent(pageDataLayer); } CreateDynamicScript(source); }; function CreateSessionCookie(name, value) { var cookie = name + "=" + value + "; path=/"; document.cookie = cookie; return value; }; function CreateDeviceCookie(name, value) { var date = new Date(2037, 1, 1); var expires = "; expires=" + date.toGMTString(); var cookie = name + "=" + value + expires + "; path=/"; document.cookie = cookie; return value; }; function DeleteCookie(name) { var date = new Date(0); var expires = "; expires=" + date.toGMTString(); var cookie = name + "=" + expires + "; path=/"; document.cookie = cookie; }; function ParseAllCookies() { var cookies = {}, i, pair, name, value, separated = document.cookie.split(';'), unparsedValue; for (i = 0; i < separated.length; i = i + 1) { pair = separated[i].split('='); name = pair[0].replace(/^\s*/, '').replace(/\s*$/, ''); try { value = decodeURIComponent(pair[1]); } catch (e1) { value = pair[1]; } cookies[name] = value; } return cookies; }; function GetCookie(cookieName) { var returnValue, item, cookies = ParseAllCookies(); if (typeof cookieName === 'string') { returnValue = (typeof cookies[cookieName] !== 'undefined') ? cookies[cookieName] : null; } else if (typeof cookieName === 'object' && cookieName !== null) { returnValue = {}; for (item in cookieName) { if (typeof cookies[cookieName[item]] !== 'undefined') { returnValue[cookieName[item]] = cookies[cookieName[item]]; } else { returnValue[cookieName[item]] = null; } } } else { returnValue = cookies; } return returnValue; }; function CallGetUUID() { var left = window.screenLeft ? window.screenLeft : window.screenX; var top = window.screenTop ? window.screenTop : window.screenY; if (!left) { left = 0; } if (!top) { top = 0; } var k = new Kybos(window.navigator.userAgent, Math.random(), left + top).fract53; var uuid = GetUUID(k); return uuid; }; function GetUUID( z, a, b // placeholders ) { for ( // loop :) b = a = ''; // b - result , a - numeric variable a++ < 36; // b += a * 51 & 52 // if "a" is not 9 or 14 or 19 or 24 ? // return a random number or 4 ( a ^ 15 // if "a" is not 15 ? // genetate a random number from 0 to 15 8 ^ z() * (a ^ 20 ? 16 : 4) // unless "a" is 20, in which case a random number from 8 to 11 : 4 // otherwise 4 ).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-" ); return b }; //Click and Impression tracking section function SaveClick(programProductId, listingTypeId, pageNumber, position, redirectURL) { //flush before anything to make sure our pageview guid is there _etq.flush(); var campaignTrackId = GetCookie("_CampaignTrackID"); var source = _serviceDomain + "/Tracking/SaveClick?pageViewGUID=" + _pageViewGUID + "&programProductID=" + encodeURI(programProductId) + "&ListingTypeID=" + encodeURIComponent(listingTypeId) + "&Position=" + encodeURIComponent(position) + "&PageNumber=" + encodeURIComponent(pageNumber) + "&redirectURL=" + encodeURIComponent(redirectURL); if(campaignTrackId) { source += "&campaignTrackId=" + encodeURI(campaignTrackId); } CreateDynamicScript(source); var win = window.open(redirectURL, '_blank'); win.focus(); }; function etImpression(args) { _etq.flush(); var listingTypeId = args[0]; var impressionCollection = args[1]; var source = _serviceDomain + "/Tracking/SaveImpression?pageViewGUID=" + encodeURI(_pageViewGUID) + "&ListingTypeID=" + encodeURIComponent(listingTypeId) + "&impressionsJSON=" + encodeURIComponent(JSON.stringify(impressionCollection)); CreateDynamicScript(source); }; //end impression and click tracking section // From http://baagoe.com/en/RandomMusings/javascript/ // Johannes Baagøe , 2010 function Mash() { var n = 0xefc8249d; var mash = function (data) { data = data.toString(); for (var i = 0; i < data.length; i++) { n += data.charCodeAt(i); var h = 0.02519603282416938 * n; n = h >>> 0; h -= n; h *= n; n = h >>> 0; h -= n; n += h * 0x100000000; // 2^32 } return (n >>> 0) * 2.3283064365386963e-10; // 2^-32 }; return mash; }; function Kybos() { return (function (args) { var c = 1; var s = []; var k = 0; var mash = Mash(); var s0 = mash(' '); var s1 = mash(' '); var s2 = mash(' '); for (var j = 0; j < 8; j++) { s[j] = mash(' '); } args.push([+new Date]); for (var i = 0; i < args.length; i++) { s0 -= mash(args[i]); if (s0 < 0) { s0 += 1; } s1 -= mash(args[i]); if (s1 < 0) { s1 += 1; } s2 -= mash(args[i]); if (s2 < 0) { s2 += 1; } for (var j = 0; j < 8; j++) { s[j] -= mash(args[i]); if (s[j] < 0) { s[j] += 1; } } } //addnoise for (var i = arguments.length - 1; i >= 0; i--) { for (j = 0; j < 8; j++) { s[j] -= mash(arguments[i]); if (s[j] < 0) { s[j] += 1; } } } var random = function () { var a = 2091639; k = s[k] * 8 | 0; var r = s[k]; var t = a * s0 + c * 2.3283064365386963e-10; // 2^-32 s0 = s1; s1 = s2; s2 = t - (c = t | 0); s[k] -= s2; if (s[k] < 0) { s[k] += 1; } return r; }; random.fract53 = function () { return random() + (random() * 0x200000 | 0) * 1.1102230246251565e-16; // 2^-53 }; random.args = args; return random; } (Array.prototype.slice.call(arguments))); };