1/*1790836956000*/ 2const InputTracking = { 3 INPUT_SELECTOR: 'data-tgm-search', 4 ENTRY_SELECTOR: 'data-tgm-entry', 5 FORM_SELECTOR: '#tgm-listener', 6 7 // Data layer for the Tag Manager. If it doesn't exist, create an empty array. 8 dataLayer: globalThis.dataLayer || [], 9 10 init() { 11 // Listen to the submit actions 12 $(document).on('submit', this.FORM_SELECTOR, this.eventListenerOnSubmit.bind(this)); 13 }, 14 15 /** 16 * Handles form submission for tracked search forms. 17 * Finds the input element that has the `data-tgm-search` attribute, reads the 18 * attribute value as the search location (for example: `header` or `body`), 19 * sanitizes the entered search term, and forwards both values to the data layer. 20 * 21 * @param event 22 */ 23 eventListenerOnSubmit(event) { 24 const input = event.currentTarget.querySelector(`input[${this.INPUT_SELECTOR}]`); 25 26 if (input) { 27 const searchLocation = input.getAttribute(this.INPUT_SELECTOR); 28 const tarievenInput = input.getAttribute(this.ENTRY_SELECTOR); 29 30 const sanitizedValue = input.value.trim().toLowerCase(); 31 32 this.pushToDataLayer(sanitizedValue, searchLocation, tarievenInput); 33 } 34 }, 35 36 /** 37 * Actual data layer push 38 * 39 * @param {string} value Sanitized search term. 40 * @param {string} search_location Origin of the search interaction (for example: header or body). 41 * @param {string} search_type Wheather search is done in the Tarieventabel searchInput. 42 */ 43 pushToDataLayer(value, search_location, search_type) { 44 const dataLayer = { 45 event: 'interaction', 46 event_category: 'content', 47 event_action: 'search', 48 event_name: value, 49 meta: { search_location, ...(search_type && {search_type}) }, 50 }; 51 52 this.dataLayer.push(dataLayer); 53 }, 54}; 55 56document.addEventListener('DOMContentLoaded', () => InputTracking.init());
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.