1(function(TYPO3, _mtm, blockAdBlock, Hst3CookieconsentHelper) { 2 "use strict"; 3 4 // Event-Tracking by data-Attributes 5 var Event = function(data) { 6 this._validTriggers = [ 7 'click', 8 'change', 9 'submit', 10 'load', 11 'ready', 12 'hover', 13 ]; 14 15 this._data = { 16 'trigger': false, 17 'event': 'maEvent', 18 'category': '', 19 'action': '', 20 'label': '', 21 'value': '' 22 }; 23 24 if (data !== undefined && data instanceof Object) { 25 for (let i in data) { 26 if(this._data[i] !== undefined) { 27 switch(i) { 28 case 'trigger': 29 if(this._validTriggers.indexOf(data[i]) !== -1) { 30 this._data[i] = data[i]; 31 } else { 32 this._data[i] = false; 33 } 34 break; 35 default: 36 this._data[i] = data[i]; 37 break; 38 } 39 } 40 } 41 } 42 43 return this; 44 }; 45 46 Event.prototype.get = function (key) { 47 return this._data[key]; 48 }; 49 50 document.querySelectorAll('[data-track]').forEach(function(element) { 51 const data = element.dataset.track; 52 53 const e = new Event(data); 54 55 if (e.get('trigger')) { 56 const trigger = e.get('trigger'); 57 58 const pushEvent = function() { 59 _mtm.push({ 60 'event': e.get('event'), 61 'eventCategory': e.get('category'), 62 'eventAction': e.get('action') ? e.get('action') : e.get('trigger'), 63 'eventLabel': e.get('label'), 64 'eventValue': e.get('value') 65 }); 66 }; 67 68 if (trigger === "load" || trigger === "ready") { 69 pushEvent(); 70 } else { 71 element.addEventListener(trigger, pushEvent); 72 } 73 } else { 74 console.log('Invalid event tracking trigger defined.'); 75 } 76 }); 77 78 // adBlocker 79 blockAdBlock.onDetected(()=> { 80 _mtm.push({ 81 'event': 'adBlocker', 82 'eventValue': 1 83 }); 84 }); 85 86 blockAdBlock.onNotDetected(() => { 87 _mtm.push({ 88 'event': 'adBlocker', 89 'eventValue': 0 90 }); 91 }); 92 93 // Origin 94 if(TYPO3.settings.PmMtm.origin !== undefined) { 95 _mtm.push({ 96 'event': 'origin', 97 'eventValue': TYPO3.settings.PmMtm.origin 98 }); 99 } 100 101 // Referrer 102 if(TYPO3.settings.PmMtm.referrer !== undefined) { 103 _mtm.push({ 104 'event': 'referrer', 105 'eventValue': TYPO3.settings.PmMtm.referrer 106 }); 107 } 108 109 // Hst3Cookieconsent 110 if (Hst3CookieconsentHelper !== undefined && Hst3CookieconsentHelper.hasOwnProperty('isCookieCategoryAccepted')) { 111 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('required')) { 112 _mtm.push({ 113 'event': 'cookie_consent_required', 114 'eventValue': 'required' 115 }); 116 } 117 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('preferences')) { 118 _mtm.push({ 119 'event': 'cookie_consent_preferences', 120 'eventValue': 'preferences' 121 }); 122 } 123 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('statistics')) { 124 _mtm.push({ 125 'event': 'cookie_consent_statistics', 126 'eventValue': 'statistics' 127 }); 128 } 129 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('marketing')) { 130 _mtm.push({ 131 'event': 'cookie_consent_marketing', 132 'eventValue': 'marketing' 133 }); 134 } 135 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('personalization')) { 136 _mtm.push({ 137 'event': 'cookie_consent_personalization', 138 'eventValue': 'personalization' 139 }); 140 } 141 if (true === Hst3CookieconsentHelper.isCookieCategoryAccepted('other')) { 142 _mtm.push({ 143 'event': 'cookie_consent_other', 144 'eventValue': 'other' 145 }); 146 } 147 } 148})(TYPO3, _mtm || [], window.blockAdBlock, Hst3CookieconsentHelper || {});
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.