1function epiGat(settings) { 2 if (settings.downloads || settings.external || settings.mailto) { 3 var isinternal = new RegExp('^' + window.location.protocol + '\/\/' + window.location.host, 'i'); 4 5 function addEvent(obj, type, fn) { 6 if (obj.addEventListener) 7 obj.addEventListener(type, fn, false); 8 else if (obj.attachEvent) { 9 obj['e' + type + fn] = fn; 10 obj[type + fn] = function () { obj['e' + type + fn](window.event); } 11 obj.attachEvent('on' + type, obj[type + fn]); 12 } 13 } 14 15 var isdownload = new RegExp('[.](' + settings.extensions + ')$', 'i'); 16 var islink = new RegExp('^https?://'); 17 var ismailto = new RegExp('^mailto:', 'i'); 18 19 function instead(e, a) { 20 var isDefaultPrevented = e.defaultPrevented; 21 22 if (e.preventDefault) e.preventDefault(); 23 else if (event) event.returnValue = false; 24 25 if (isDefaultPrevented == false) { 26 setTimeout(function () { window.location = a.href; }, 200); 27 } 28 } 29 30 // https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs#events 31 addEvent(document, 'click', function (e) { 32 e = e || event; 33 var a = e.target || e.srcElement; 34 35 // Depend on TrackScriptOption to decided Clasic or Universal or Customer 36 var trackingEvent = function (category, action, opt_label, opt_value) { 37 gtag('event', action, { 38 'event_category':category, 39 'event_label':opt_label, 40 'event_value':opt_value 41 }); 42 }; 43 44 // Depend on TrackScriptOption to decided Clasic or Universal or Customer 45 var trackingPageView = function (path) { 46 gtag('event', 'page_view', { 47 'page_location': path 48 }); 49 }; 50 51 for (; a.parentNode; a = a.parentNode) { 52 if (a.tagName !== 'A') { 53 continue; 54 } 55 56 if (settings.downloads && isdownload.test(a.href)) { 57 var extension = isdownload.exec(a.href); 58 trackingEvent('Download', 'Download', extension[1].toUpperCase(), a.href.replace(isinternal, '')); 59 60 if (!a.target || a.target === "_top") 61 instead(e, a); 62 } 63 else if (settings.external && islink.test(a.href) && !isinternal.test(a.href)) { 64 if (settings.externalsAsViews) { 65 trackingPageView('/external/' + a.href.replace(islink, '')); 66 } else { 67 trackingEvent('External', 'External', 'Clicked', a.href); 68 } 69 if (!a.target || a.target === "_top") 70 instead(e, a); 71 } 72 else if (settings.mailto && ismailto.test(a.href)) { 73 trackingEvent('Mailto', 'Mailto', 'Clicked', a.href.replace(ismailto, '')); 74 } 75 76 return; 77 } 78 }); 79 } 80 81 // if track post of the EPiServer.Forms 82 if (settings.trackForms == true) { 83 84 if (typeof $$epiforms == "undefined" || !$$epiforms) { 85 return; 86 } 87 88 $$epiforms(document).ready(function () { 89 90 $$epiforms(".EPiServerForms").on("formsSubmitted", function (event) { 91 92 if (event.isFinalizedSubmission != true) { 93 return; 94 } 95 96 var gaEventCategory = "EPiServer Forms"; 97 var gaEventLabel = event.workingFormInfo.Id; 98 var gaEventAction = "EPiForm_" + event.workingFormInfo.Name; 99 100 gtag('event', gaEventAction, { 101 'event_category':gaEventCategory, 102 'event_label':gaEventLabel, 103 'event_value':1 104 }); 105 }); 106 }); 107 } 108};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.