1(function() { 2 3 'use strict'; 4 5 window.jzlFord = window.jzlFord || {}; 6 window.jzlFord.dtm = { 7 /** 8 * Finds a matching event name in the DTM Events Mapping 9 * 10 * @param pageLoadType string Type of the current page 11 * @param pageLoadSubType string Sub-type of the current page 12 * @param eventDetails Object Information about the current event 13 * @returns {{}|*} 14 */ 15 findMatchInMapping: function (pageLoadType, pageLoadSubType, eventDetails) { 16 17 if ( eventDetails == null || Object.keys(eventDetails).length < 1) { 18 return null; 19 } 20 21 var dtmEventsMap = window.jzlFord.dtm.getEventsMapping(); 22 var dtmEvent = null; 23 24 // Find event that matches the current event's name 25 for (var i = 0; i < dtmEventsMap.length; i++) { 26 27 var event = dtmEventsMap[i]; 28 if (event.name === eventDetails.event) { 29 30 // Find mapping that matches the current page's type 31 dtmEvent = event.mapping.filter(function (mapping) { 32 33 var pageTypeMatched = mapping.pageType === '*' || mapping.pageType === pageLoadType; 34 var pageSubTypeMatched = mapping.pageSubType === '*' || mapping.pageSubType === pageLoadSubType; 35 36 return pageTypeMatched && pageSubTypeMatched; 37 38 })[0] || null; 39 40 if (dtmEvent != null) { 41 42 eventDetails.data = eventDetails.data || {}; 43 44 if ( dtmEvent.parameters != null ) { 45 46 eventDetails.data.params = {}; 47 for ( var param in dtmEvent.parameters ) { 48 if ( dtmEvent.parameters.hasOwnProperty(param) ) { 49 eventDetails.data.params[param] = dtmEvent.parameters[param]; 50 } 51 } 52 } 53 54 if ( dtmEvent.tags != null ) { 55 56 eventDetails.data.tags = {}; 57 for ( var tag in dtmEvent.tags ) { 58 if ( dtmEvent.tags.hasOwnProperty(tag) ) { 59 eventDetails.data.tags[tag] = dtmEvent.tags[tag]; 60 } 61 } 62 } 63 64 return { 65 source: eventDetails.source, 66 action: dtmEvent.action, 67 data: eventDetails.data, 68 } 69 } 70 } 71 } 72 73 var formattedPageType = pageLoadType.toUpperCase(); 74 var formattedPageSubType = pageLoadSubType ? pageLoadSubType.toUpperCase() : 'NONE'; 75 console.log('[INFO] DTM - Did not find a matching DTM Event for pageType "' + formattedPageType + '" with subType "' + formattedPageSubType + '"', eventDetails); 76 77 return null; 78 } 79 } 80})();
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.