1(function ($, Drupal) { 2 "use strict"; 3 4 let CE_eventParams = []; 5 6 Drupal.behaviors.ceEventTracker = { 7 attach: function (context, settings) { 8 // Event download. 9 $(".interaction.download a, .resources.resources-download a").click( 10 function () { 11 const document_title = $(this).text().trim(); // Link title. 12 13 const lb_interaction = "download"; 14 const lb_global_context = "content"; 15 const lb_local_context = "document"; 16 const lb_free_slot = document_title; 17 const lb_category = _extractFileExtension($(this).prop("href")); // PDF|DOC|DOCX|ETC.. 18 19 const heading_hierarchy = [ 20 lb_global_context, 21 lb_local_context, 22 lb_free_slot, 23 lb_category, 24 ].join("::"); 25 const component_hierarchy = [ 26 lb_global_context, 27 lb_interaction, 28 lb_local_context, 29 ].join("_>_"); 30 31 CE_eventParams.push("actionname", "download::" + heading_hierarchy); 32 CE_eventParams.push("actionmode", ""); // Action mode empty according to the documentation. 33 CE_eventParams.push( 34 "actionlabel", 35 [ 36 lb_interaction, 37 lb_global_context, 38 lb_local_context, 39 lb_free_slot, 40 lb_category, 41 ].join(",") 42 ); // Concatenation of 5 elements: interaction, global_context, local_context, free_slot, category. 43 CE_eventParams.push("actionpname", "component_label"); 44 CE_eventParams.push("actionpvalue", document_title); 45 CE_eventParams.push("actionpname", "component_hierarchy"); 46 CE_eventParams.push("actionpvalue", component_hierarchy); 47 CE_eventParams.push("actionpname", "heading_hierarchy"); 48 CE_eventParams.push("actionpvalue", heading_hierarchy); 49 50 CE_trackEvent("action", "download", CE_eventParams); 51 CE_eventParams = []; // Clear the params to prepare next event to push. 52 } 53 ); 54 55 // Event search. 56 $("#site-search").submit( 57 function () { 58 const search_terms = _extractSearchTerms($(this).serializeArray()); 59 const lb_interaction = "search"; 60 const lb_global_context = "header"; 61 const lb_local_context = "button"; 62 const lb_free_slot = search_terms; // Keywords from research. 63 const lb_category = "custom_event"; 64 65 const heading_hierarchy = [ 66 lb_global_context, 67 lb_local_context, 68 lb_free_slot, 69 lb_category, 70 ].join("::"); 71 const component_hierarchy = [ 72 lb_global_context, 73 lb_interaction, 74 lb_local_context, 75 ].join("_>_"); 76 77 CE_eventParams.push("actionname", "search::" + heading_hierarchy); 78 CE_eventParams.push("actionmode", ""); // Action mode empty according to the documentation. 79 CE_eventParams.push( 80 "actionlabel", 81 [ 82 lb_interaction, 83 lb_global_context, 84 lb_local_context, 85 lb_free_slot, 86 lb_category, 87 ].join(",") 88 ); // Concatenation of 5 elements: interaction, global_context, local_context, free_slot, category. 89 CE_eventParams.push("actionpname", "component_value");
90 CE_eventParams.push("actionpvalue", search_terms); 91 CE_eventParams.push("actionpname", "component_hierarchy"); 92 CE_eventParams.push("actionpvalue", component_hierarchy); 93 CE_eventParams.push("actionpname", "heading_hierarchy"); 94 CE_eventParams.push("actionpvalue", heading_hierarchy); 95 96 CE_trackEvent("action", "search::button", CE_eventParams); 97 CE_eventParams = []; // Clear the params to prepare next event to push. 98 } 99 ); 100 101 // Event add a schedule to calendar. 102 $("#addToCalendar dsa-button").click( 103 function () { 104 const click_label = $(this).text().trim(); 105 const lb_interaction = "click"; 106 const lb_global_context = "content"; 107 const lb_local_context = "button"; 108 const lb_free_slot = click_label; 109 const lb_category = "add_to_calendar_button"; 110 111 const heading_hierarchy = [ 112 lb_global_context, 113 lb_local_context, 114 lb_free_slot, 115 lb_category, 116 ].join("::"); 117 const component_hierarchy = [ 118 lb_global_context, 119 lb_interaction, 120 "dsa-button", 121 ].join("_>_"); 122 123 CE_eventParams.push("actionname", "click::" + heading_hierarchy); 124 CE_eventParams.push("actionmode", ""); // Action mode empty according to the documentation. 125 CE_eventParams.push( 126 "actionlabel", 127 [ 128 lb_interaction, 129 lb_global_context, 130 lb_local_context, 131 lb_free_slot, 132 lb_category, 133 ].join(",") 134 ); // Concatenation of 5 elements: interaction, global_context, local_context, free_slot, category. 135 CE_eventParams.push("actionpname", "component_label"); 136 CE_eventParams.push("actionpvalue", click_label); 137 CE_eventParams.push("actionpname", "component_hierarchy"); 138 CE_eventParams.push("actionpvalue", component_hierarchy); 139 CE_eventParams.push("actionpname", "heading_hierarchy"); 140 CE_eventParams.push("actionpvalue", heading_hierarchy); 141 142 CE_trackEvent("action", "Add to calendar button", CE_eventParams); 143 CE_eventParams = []; // Clear the params to prepare next event to push. 144 } 145 ); 146 147 // Event filter by tag. 148 $(".categories .chip a").each( 149 function (i) { 150 $(this).click( 151 function () { 152 const header_label = $(this).text().trim(); 153 const lb_interaction = "click"; 154 const lb_global_context = "content"; 155 const lb_local_context = "link"; 156 const lb_free_slot = header_label; 157 const lb_category = "tags_button"; 158 159 const heading_hierarchy = [ 160 lb_global_context, 161 lb_local_context, 162 lb_free_slot, 163 lb_category, 164 ].join("::"); 165 const component_hierarchy = [ 166 lb_global_context, 167 lb_interaction, 168 lb_local_context, 169 ].join("_>_"); 170 171 CE_eventParams.push("actionname", "click::" + heading_hierarchy); 172 CE_eventParams.push("actionmode", ""); // Action mode empty according to the documentation.
173 CE_eventParams.push( 174 "actionlabel", 175 [ 176 lb_interaction, 177 lb_global_context, 178 lb_local_context, 179 lb_free_slot, 180 lb_category, 181 ].join(",") 182 ); // Concatenation of 5 elements: interaction, global_context, local_context, free_slot, category. 183 CE_eventParams.push("actionpname", "component_label"); 184 CE_eventParams.push("actionpvalue", header_label); 185 CE_eventParams.push("actionpname", "component_hierarchy"); 186 CE_eventParams.push("actionpvalue", component_hierarchy); 187 CE_eventParams.push("actionpname", "heading_hierarchy"); 188 CE_eventParams.push("actionpvalue", heading_hierarchy); 189 190 CE_trackEvent("action", "topic / tags", CE_eventParams); 191 CE_eventParams = []; // Clear the params to prepare next event to push. 192 } 193 ); 194 } 195 ); 196 197 // Event navigation bar usage. 198 $(".main-sections .big-menu ul li a, .main-sections .menu > button").each( 199 function (i) { 200 $(this).click( 201 function () { 202 const header_label = $(this).text().trim(); 203 const lb_interaction = "click"; 204 const lb_global_context = "navigation"; 205 const lb_local_context = "button"; 206 const lb_free_slot = header_label; 207 const lb_category = "navigation_bar"; 208 209 const heading_hierarchy = [ 210 lb_global_context, 211 lb_local_context, 212 lb_free_slot, 213 lb_category, 214 ].join("::"); 215 const component_hierarchy = [ 216 lb_global_context, 217 lb_interaction, 218 lb_local_context, 219 ].join("_>_"); 220 221 CE_eventParams.push("actionname", "click::" + heading_hierarchy); 222 CE_eventParams.push("actionmode", ""); // Action mode empty according to the documentation. 223 CE_eventParams.push( 224 "actionlabel", 225 [ 226 lb_interaction, 227 lb_global_context, 228 lb_local_context, 229 lb_free_slot, 230 lb_category, 231 ].join(",") 232 ); // Concatenation of 5 elements: interaction, global_context, local_context, free_slot, category. 233 CE_eventParams.push("actionpname", "component_label"); 234 CE_eventParams.push("actionpvalue", header_label); 235 CE_eventParams.push("actionpname", "component_hierarchy"); 236 CE_eventParams.push("actionpvalue", component_hierarchy); 237 CE_eventParams.push("actionpname", "heading_hierarchy"); 238 CE_eventParams.push("actionpvalue", heading_hierarchy); 239 240 CE_trackEvent("action", "header", CE_eventParams); 241 CE_eventParams = []; // Clear the params to prepare next event to push. 242 } 243 ); 244 } 245 ); 246 }, 247 }; 248})(jQuery, Drupal); 249 250/** 251 * Extract the url file extension of document. 252 * 253 * @param {string} data 254 * @returns 255 */ 256const _extractFileExtension = (data) => { 257 return data.split("?")[0].split("#")[0].split(".").pop() || ""; 258}; 259 260/** 261 * Extract the url file name of document. 262 * 263 * @param {string} data 264 * @returns 265 */ 266const _extractFileName = (data) => { 267 return data.split("/").pop().trim() || ""; 268}; 269 270/** 271 * Extract keywords from a reserach. 272 * 273 * @param {Object} data 274 */ 275const _extractSearchTerms = (data) => { 276 return data[0].value.split(" ").join(",") || "No term."; 277}; 278 279/** 280 * Send event to Eulerian. 281 * 282 * @param {string} CE_eventType 283 * @param {string} CE_eventName 284 * @param {array}
284 CE_eventParams 285 */ 286const CE_trackEvent = (CE_eventType, CE_eventName, CE_eventParams) => { 287 // First 'EA_push' push custom parameters to associate them to event. 288 // EA_push('globalarg', CE_eventParams); 289 290 // Second 'EA_push' to push event. 291 EA_push(CE_eventType, CE_eventParams); 292 293 // Last 'EA_push' call to clear "globalarg" between two calls. 294 // More details - https://eulerian.wiki/doku.php?id=fr:modules:collect:onsite_collection:eaevents 295 // EA_push('globalarg', []); 296};
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.