https://ritholtz.com/wp-content/plugins/gravitate-event-tracking/gravitate_event_tracking.js?v=1.5.3
1jQuery(function($) 2{ 3 4 var GETGA_scroll_depths = ['25','50','75','100']; 5 GETGA_scroll_depths['25'] = []; 6 GETGA_scroll_depths['50'] = []; 7 GETGA_scroll_depths['75'] = []; 8 GETGA_scroll_depths['100'] = []; 9 10 var GETGA_has_scrolled = []; 11 var GETGA_has_resized = []; 12 13 function getga_debug(msg) 14 { 15 if(typeof GETGA_settings['debug'] !== 'undefined') 16 { 17 if(GETGA_settings['debug'] === 'alert') 18 { 19 alert(msg); 20 } 21 else if(GETGA_settings['debug'] === 'console') 22 { 23 console.log(msg); 24 } 25 } 26 } 27 28 function getga_add_event_tracking(getga_event) 29 { 30 if(typeof getga_event['selector'] !== 'undefined') 31 { 32 if(getga_event['selector'] === 'window') 33 { 34 getga_event['selector'] = window; 35 } 36 37 if(getga_event['selector'] === 'document') 38 { 39 getga_event['selector'] = document; 40 } 41 42 $(getga_event['selector']).on(getga_event['action_type'].replace('depth', ''), function(e){ 43 44 var scrolled_perc = 0; 45 46 var label = getga_event['label']; 47 48 var labelKey = getga_event['selector']+'_'+getga_event['action_type']+'_'+label; 49 50 if(getga_event['action_type'] === 'resize') 51 { 52 if($.inArray(labelKey, GETGA_has_resized) > -1) 53 { 54 return false; 55 } 56 GETGA_has_resized.push(labelKey); 57 } 58 else if(getga_event['action_type'] === 'scroll') 59 { 60 if($.inArray(labelKey, GETGA_has_scrolled) > -1) 61 { 62 return false; 63 } 64 GETGA_has_scrolled.push(labelKey); 65 } 66 else if(getga_event['action_type'] === 'scrolldepth') 67 { 68 var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height(); 69 scrolled_perc = ((wintop/(docheight-winheight))*100); 70 71 if(scrolled_perc < 25) 72 { 73 return false; 74 } 75 76 if(scrolled_perc >= 25 && scrolled_perc < 50) 77 { 78 if($.inArray(labelKey, GETGA_scroll_depths['25']) > -1) 79 { 80 return false; 81 } 82 GETGA_scroll_depths['25'].push(labelKey); 83 scrolled_perc = 25; 84 } 85 86 if(scrolled_perc >= 50 && scrolled_perc < 75) 87 { 88 if($.inArray(labelKey, GETGA_scroll_depths['50']) > -1) 89 { 90 return false; 91 } 92 GETGA_scroll_depths['50'].push(labelKey); 93 scrolled_perc = 50; 94 } 95 96 if(scrolled_perc >= 75 && scrolled_perc < 99) 97 { 98 if($.inArray(labelKey, GETGA_scroll_depths['75']) > -1) 99 { 100 return false; 101 } 102 GETGA_scroll_depths['75'].push(labelKey); 103 scrolled_perc = 75; 104 } 105 106 if(scrolled_perc >= 99) 107 { 108 if($.inArray(labelKey, GETGA_scroll_depths['100']) > -1) 109 { 110 return false; 111 } 112 GETGA_scroll_depths['100'].push(labelKey); 113 scrolled_perc = 100; 114 } 115 } 116 117 var NA = 'undefined'; 118 119 getga_debug('GETGA: Selector '+getga_event['action_type']+' ('+getga_event['selector']+')'); 120 121 if(label.indexOf("{ITEM_TITLE}") > -1) 122 { 123 label = label.replace("{ITEM_TITLE}", ($(this).attr('title') !== undefined ? $(this).attr('title') : NA)); 124 } 125 if(label.indexOf("{PAGE_URL}") > -1) 126 { 127 label = label.replace("{PAGE_URL}", location.href); 128 } 129 if(label.indexOf("{PAGE_RELATIVE_URL}") > -1) 130 { 131 label = label.replace("{PAGE_RELATIVE_URL}", location.pathname); 132 } 133 if(label.indexOf("{LINK_URL}
133") > -1) 134 { 135 label = label.replace("{LINK_URL}", ($(this).attr('href') !== undefined ? $(this).attr('href') : NA)); 136 } 137 if(label.indexOf("{LINK_RELATIVE_URL}") > -1) 138 { 139 label = label.replace("{LINK_RELATIVE_URL}", ($(this).attr('href') !== undefined ? $(this).attr('href').replace(/^(?:\/\/|[^\/]+)*\//, '/') : NA)); 140 } 141 if(label.indexOf("{IMAGE_SRC}") > -1) 142 { 143 label = label.replace("{IMAGE_SRC}", ($(this).attr('src') !== undefined ? $(this).attr('src') : NA)); 144 } 145 if(label.indexOf("{IMAGE_ALT}") > -1) 146 { 147 label = label.replace("{IMAGE_ALT}", ($(this).attr('alt') !== undefined ? $(this).attr('alt') : NA)); 148 } 149 if(label.indexOf("{TAG_HTML}") > -1) 150 { 151 label = label.replace("{TAG_HTML}", $(this).html().replace(/(<([^>]+)>)/ig,'').replace(/(\r\n|\n|\r)/gm,'').replace(/\s{2,}/g, ' ')); 152 } 153 if(label.indexOf("{SCROLL_PERCENTAGE}") > -1) 154 { 155 label = label.replace("{SCROLL_PERCENTAGE}", scrolled_perc); 156 } 157 158 if(typeof ga === 'undefined' && typeof __gaTracker !== 'undefined') 159 { 160 try 161 { 162 __gaTracker('send', 'event', getga_event['category'], getga_event['action_label'], label); 163 getga_debug("GETGA: Sent to Universal Tracking [ __gaTracker('send', 'event', '"+getga_event['category']+"', '"+getga_event['action_label']+"', '"+label+"'); ]"); 164 } 165 catch(err) 166 { 167 getga_debug('GETGA: [ERROR] Sending to Universal Tracking via __gaTracker ('+err+')'); 168 } 169 } 170 else if(typeof ga !== 'undefined') 171 { 172 try 173 { 174 // Update to work with GTM 175 var getga_tracker = ga.getAll()[0]; 176 if(typeof getga_tracker !== 'undefined' && getga_tracker) 177 { 178 getga_tracker.send('event', getga_event['category'], getga_event['action_label'], label); 179 getga_debug("GETGA: Sent to Universal Tracking [ getga_tracker.send('event', '"+getga_event['category']+"', '"+getga_event['action_label']+"', '"+label+"'); ]"); 180 } 181 else 182 { 183 ga('send', 'event', getga_event['category'], getga_event['action_label'], label); 184 getga_debug("GETGA: Sent to Universal Tracking [ ga('send', 'event', '"+getga_event['category']+"', '"+getga_event['action_label']+"', '"+label+"'); ]"); 185 } 186 } 187 catch(err) 188 { 189 getga_debug('GETGA: [ERROR] Sending to Universal Tracking via ga ('+err+')'); 190 } 191 } 192 else if(typeof _gaq !== 'undefined') 193 { 194 try 195 { 196 _gaq.push(['_trackEvent', getga_event['category'], getga_event['action_label'], label]); 197 getga_debug("GETGA: Sent to Standard Tracking [ _gaq.push(['_trackEvent', '"+getga_event['category']+"', '"+getga_event['action_label']+"', '"+label+"']); ]"); 198 } 199 catch(err) 200 { 201 getga_debug('GETGA: [ERROR] Sending to Standard Tracking ('+err+')'); 202 } 203 204 } 205 else 206 { 207 getga_debug('GETGA: [ERROR] Google Analytics not found (Missing all _gaq, ga, and __gaTracker)'); 208 } 209 }); 210 } 211 } 212 213 function getga_add_external_class(host) 214 { 215 $('a').each(function() { 216 if ((!host.test(this.href) && this.href.slice(0, 1) != "/" && this.href.slice(0, 1) != "#" && this.href.slice(0, 1) != "?" && this.href.slice(0, 10) != "javascript")) { 217 $(this).addClass('gtrackexternal'); 218 } 219 }); 220 } 221 222 function getga_has_ga() 223 { 224 if (typeof _gaq !== 'undefined' || typeof ga !== 'undefined' || typeof __gaTracker !== 'undefined') // Check if Google Analytics is Loaded 225 { 226 return true; 227 } 228 229 return false; 230 } 231 232 function getga_load_event_tracking() 233 { 234 if(typeof jQuery !== 'undefined') // Check if jQuery is Loaded 235 { 236 getga_debug('GETGA: Found jQuery.'); 237 238 if(getga_has_ga()) // Check if Google Analytics is Loaded 239 { 240 getga_debug('GETGA: Found Google Analytics'); 241 getga_add_all_event_tracking(); 242 } 243 else 244 { 245 getga_debug('GETGA: [ERROR] Missing Google Analytics. Trying Again...'); 246 247 setTimeout(function() 248 { 249 if(getga_has_ga()) // Check if Google Analytics is Loaded 250 { 251 getga_debug('GETGA: Found Google Analytics'); 252 getga_add_all_event_tracking(); 253 } 254 else 255 { 256 setTimeout(function() 257 { 258 if(getga_has_ga()) // Check if Google Analytics is Loaded 259 { 260 getga_debug('GETGA: Found Google Analytics after First Delay'); 261 getga_add_all_event_tracking(); 262 } 263 else 264 { 265 getga_debug('GETGA: [ERROR] Still Missing Google Analytics. Trying Again...'); 266 267 setTimeout(function() 268 { 269 if(getga_has_ga()) // Check if Google Analytics is Loaded 270 { 271 getga_debug('GETGA: Found Google Analytics after Second Delay'); 272 getga_add_all_event_tracking(); 273 } 274 else 275 { 276 getga_debug('GETGA: [ERROR] Still Missing Google Analytics. Please review that you have loaded Google Analytics Properly.'); 277 } 278 279 280 }, (GETGA_settings['second_delay']*1000)); 281 } 282 283 }, (GETGA_settings['first_delay']*1000)); 284 } 285 286 }, 500); 287 } 288 } 289 else 290 { 291 getga_debug('GETGA: [ERROR] Missing jQuery.'); 292 } 293 } 294 295 function getga_add_all_event_tracking() 296 { 297 var evt, 298 txt, 299 selector, 300 loadedKey, 301 loaded = [], 302 host = new RegExp('/' + window.location.host + '/'); 303 304 if(typeof GETGA_events !== 'undefined') 305 { 306 for(evt in GETGA_events) 307 { 308 txt = document.createElement("textarea"); 309 txt.innerHTML = GETGA_events[evt]['selector']; 310 selector = txt.value.replace(/\\/g, ''); 311 312 GETGA_events[evt]['selector'] = selector; 313 314 loadedKey = selector+'_'+GETGA_events[evt]['action_type']+'_'+GETGA_events[evt]['label']; 315 316 if($.inArray(loadedKey, loaded) < 0) 317 { 318 loaded.push(loadedKey); 319 320 if(typeof GETGA_events[evt]['status'] !== 'undefined' && typeof selector !== 'undefined') 321 { 322 if(GETGA_events[evt]['status'] === 'active') 323 { 324 if(selector === '.gtrackexternal') 325 { 326 getga_add_external_class(host); 327 } 328 329 if(selector === 'window') 330 { 331 selector = window; 332 } 333 334 if(selector === 'document') 335 { 336 selector = document; 337 } 338 339 if($(selector).length) 340 { 341 getga_add_event_tracking(GETGA_events[evt]); 342 getga_debug('GETGA: Found selector ('+selector+')'); 343 } 344 else if(GETGA_settings['first_delay']) 345 { 346 setTimeout(function(GETGA_event, selector) 347 { 348 if(selector === '.gtrackexternal') 349 { 350 getga_add_external_class(host); 351 } 352 353 if($(selector).length) 354 { 355 getga_add_event_tracking(GETGA_event); 356 getga_debug('GETGA: Found Selector after First Delay ('+selector+')'); 357 } 358 else if(GETGA_settings['second_delay']) 359 { 360 setTimeout(function(GETGA_event, selector) 361 { 362 if(selector === '.gtrackexternal') 363 { 364 getga_add_external_class(host); 365 } 366 367 if(!$(selector).length) 368 { 369 getga_debug('GETGA: Still could NOT find selector ('+selector+') Will try and add the listener anyways.'); 370 } 371 getga_add_event_tracking(GETGA_event); 372 373 }, (GETGA_settings['second_delay']*1000), GETGA_event, selector); 374 375 getga_debug('GETGA: Did NOT find selector ('+selector+') Will check again in '+GETGA_settings['second_delay']+' seconds.'); 376 } 377 378 }, (GETGA_settings['first_delay']*1000), GETGA_events[evt], selector); 379 380 getga_debug('GETGA: Did NOT find selector ('+selector+') Will check again in '+GETGA_settings['first_delay']+' seconds.'); 381 } 382 } 383 } 384 } 385 } 386 } 387 } 388 389 getga_load_event_tracking(); 390 391}
391);
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.