1/** 2 * UMW Analytics 3 * External and event tracking code 4 * @version 0.3.16 5 */ 6 7var UMWGA4 = UMWGA4 || { 8 'ga4_exists' : function() { 9 return 'undefined' !== typeof( gtag ); 10 }, 11 'doClick' : function ( e ) { 12 if ( ! UMWGA4.ga4_exists() ) { 13 return true; 14 } 15 16 var tmpArgs = { 17 'app_name' : 'Unidentified Site', 18 'screen_name' : 'Unidentified Page', 19 } 20 } 21} 22 23var UMWAnalytics = UMWAnalytics || { 24 'timeout' : 100, 25 'init' : function() { 26 }, 27 'gaExists' : function() { 28 if ( 'undefined' === typeof( ga ) ) { 29 return false; 30 } 31 return true; 32 }, 33 'doClick' : function( e ) { 34 if ( UMWAnalytics.gaExists() ) { 35 var tmpArgs = { 36 'hitType': 'event', // Required. 37 'eventCategory' : jQuery( e ).attr( 'analytics-category' ), 38 'eventAction' : jQuery( e ).attr( 'analytics-action' ), 39 'eventLabel' : jQuery( e ).attr( 'analytics-label' ), 40 'eventValue' : 1, 41 'field' : { 'nonInteraction': 1 } 42 }; 43 UMWAnalytics.log( 'Preparing to send the following args to Analytics:' ); 44 UMWAnalytics.log( tmpArgs ); 45 ga('send', tmpArgs); 46 ga('2015UMWProfile.send', tmpArgs); 47 } 48 return true; 49 }, 50 'elementExists' : function( e ) { 51 return document.querySelectorAll( e ).length > 0; 52 }, 53 'log' : function( m ) { 54 if ( typeof( console ) !== 'undefined' ) { 55 console.log( m ); 56 } else { 57 return false; 58 } 59 } 60}; 61 62jQuery( function() { 63 if( UMWAnalytics.gaExists() != true ) { 64 return; 65 } 66 67 // Creating custom :external selector 68 jQuery.expr[':'].external = function(obj){ 69 return !obj.href.match(/^mailto\:/) 70 && (obj.hostname != location.hostname); 71 }; 72 73 // Add 'external' CSS class to all external links 74 jQuery('a').filter( function() { 75 return this.hostname != location.hostname && this.hostname in umw_internal_sites; 76 } ).attr( 'analytics-cross-domain', 'yes' ).on( 'click', function(e) { 77 // Avoid doing anything with mega-menu items that are just supposed to open sub-menus 78 if ( jQuery( this ).closest( 'ul.mega-menu' ).length > 0 && jQuery( this ).closest( 'ul.mega-menu' ).attr( 'data-event' ) == 'click' ) { 79 return; 80 } 81 82 return true; 83 } ); 84 85 // Track the new Online Tools toolbar links 86 // Works on all implementations of online toolbar 87 if ( UMWAnalytics.elementExists( '.umw-helpful-links .umw-tools' ) ) { 88 jQuery( '.umw-helpful-links .umw-tools a[href!="#"][href][href!=""]' ).each( function() { 89 var tmpAction = 'Online Tools'; 90 var tmpLabel = jQuery( this ).text(); 91 92 jQuery( this ) 93 .attr( 'analytics-category', 'Helpful Links' ) 94 .attr( 'analytics-action', tmpAction ) 95 .attr( 'analytics-label', tmpLabel ); 96 97 jQuery( this ).on( 'click', function(e) { 98 var tmpResult = UMWAnalytics.doClick( this ); 99 /*UMWAnalytics.log( tmpResult );*/ 100 return tmpResult; 101 } ); 102 } ); 103 } 104 105 // Track header Audience Menu clicks 106 // Works on both sites 107 if ( UMWAnalytics.elementExists( '.umw-audience-menu' ) ) { 108 jQuery( '.umw-audience-menu a[href!="#"][href][href!=""]' ).each( function() { 109 var tmpAction = 'Audience Menu'; 110 var tmpLabel = jQuery( this ).text(); 111 112 jQuery( this ) 113 .attr( 'analytics-category', 'UMW Header Bar' ) 114 .attr( 'analytics-action', tmpAction ) 115 .attr( 'analytics-label', tmpLabel ); 116 117 jQuery( this ).on( 'click', function(e) { 118 var tmpResult = UMWAnalytics.doClick( this ); 119 /*UMWAnalytics.log( tmpResult );*/ 120 return tmpResult; 121 } ); 122 } ); 123 } 124 125 // Track Footer Links clicks on old website 126 if ( UMWAnalytics.elementExists( '#footer' ) ) { 127 jQuery( '#footer a[href!="#"][href][href!=""]' ).each( function() { 128 var tmpAction = null; 129 var tmpLabel = null; 130 if ( jQuery( this ).closest( '.umw-viewbook' ).length > 0 ) { 131 tmpAction = 'Viewbook Link'; 132 tmpLabel = jQuery( this ).closest( '.international-viewbook' ).length > 0 ? 'International Viewbook' : 'Standard Viewbook'; 133 } else if ( jQuery( this ).closest( '#umw-footer-nav' ).length > 0 ) { 134 tmpAction = 'Mega Footer Navigation'; 135 tmpLabel = jQuery( this ).text(); 136 } else { 137 tmpAction = 'Global Footer Links'; 138 tmpLabel = jQuery( this ).text(); 139 } 140 141 jQuery( this ) 142 .attr( 'analytics-category', 'Footer Links' ) 143 .attr( 'analytics-action', tmpAction ) 144 .attr( 'analytics-label', tmpLabel ); 145 146 jQuery( this ).on( 'click', function(e) { 147 var tmpResult = UMWAnalytics.doClick( this ); 148 /*UMWAnalytics.log( tmpResult );*/ 149 return tmpResult; 150 } ); 151 } ); 152 } 153 154 // Track Header Links clicks on old website 155 if ( UMWAnalytics.elementExists( '#header #umw-subnav' ) ) { 156 jQuery( '#header #umw-subnav a[href!="#"][href][href!=""]' ).each( function() { 157 var tmpAction = 'Top-Level Header Navigation'; 158 var tmpLabel = jQuery( this ).text(); 159 160 jQuery( this ) 161 .attr( 'analytics-category', 'Header Links' ) 162 .attr( 'analytics-action', tmpAction ) 163 .attr( 'analytics-label', tmpLabel ); 164 165 jQuery( this ).on( 'click', function(e) { 166 var tmpResult = UMWAnalytics.doClick( this ); 167 /*UMWAnalytics.log( tmpResult );*/ 168 return tmpResult; 169 } ); 170 } ); 171 } 172 173 // Track other home page clicks on old site 174 if ( UMWAnalytics.elementExists( 'body.network-www.site-root.home' ) ) { 175 jQuery( '#home-middle a[href!="#"][href][href!=""]' ).each( function() { 176 var tmpAction = jQuery( this ).closest( '.widget' ).find( '.widgettitle' ).text(); 177 var tmpLabel = jQuery( this ).text(); 178 if ( tmpLabel == '' && jQuery( this ).find( 'img' ).length > 0 ) { 179 if ( jQuery( this ).closest( '.post' ).length > 0 ) { 180 tmpLabel = jQuery( this ).closest( '.post' ).find( 'h2' ).text(); 181 } else { 182 tmpLabel = jQuery( this ).find( 'img' ).attr( 'alt' ); 183 } 184 } 185 186 jQuery( this ) 187 .attr( 'analytics-category', 'Home Page Links' ) 188 .attr( 'analytics-action', tmpAction ) 189 .attr( 'analytics-label', tmpLabel ); 190 191 jQuery( this ).on( 'click', function(e) { 192 var tmpResult = UMWAnalytics.doClick( this ); 193 /*UMWAnalytics.log( tmpResult );*/ 194 return tmpResult; 195 } ); 196 } ); 197 } 198
199 // Track Footer Links clicks on new website 200 if ( UMWAnalytics.elementExists( '.umw-global-footer' ) ) { 201 jQuery( '.umw-global-footer a[href!="#"][href][href!=""]' ).each( function() { 202 var tmpAction = null; 203 var tmpLabel = null; 204 if ( jQuery( this ).closest( '.primary-global-footer' ).length > 0 ) { 205 tmpAction = 'Primary Footer Area'; 206 tmpLabel = jQuery( this ).text(); 207 } else if ( jQuery( this ).closest( '.secondary-global-footer' ).length > 0 ) { 208 tmpAction = 'Secondary Footer Area'; 209 tmpLabel = jQuery( this ).text(); 210 } else { 211 tmpAction = 'Additional Global Footer Links'; 212 tmpLabel = jQuery( this ).text(); 213 } 214 215 jQuery( this ) 216 .attr( 'analytics-category', 'Footer Links' ) 217 .attr( 'analytics-action', tmpAction ) 218 .attr( 'analytics-label', tmpLabel ); 219 220 jQuery( this ).on( 'click', function(e) { 221 var tmpResult = UMWAnalytics.doClick( this ); 222 /*UMWAnalytics.log( tmpResult );*/ 223 return tmpResult; 224 } ); 225 } ); 226 } 227 228 // Track Header Links clicks on new site 229 if ( UMWAnalytics.elementExists( '.umw-global-header' ) ) { 230 jQuery( '.umw-global-header a[href!="#"][href][href!=""]' ).each( function() { 231 // Skip over any links that are just supposed to open the mega menu 232 if ( jQuery( this ).closest( 'ul' ).hasClass( 'mega-menu' ) && jQuery( this ).closest( '.mega-menu' ).attr( 'data-event' ) == 'click' ) { 233 return; 234 } 235 236 var tmpAction = 'Global Header Navigation'; 237 var tmpLabel = ''; 238 if ( jQuery( this ).find( 'svg' ).length > 0 ) { 239 tmpLabel = jQuery( this ).find( 'svg' ).find( 'title' ).text(); 240 } else if ( jQuery( this ).find( 'img' ).length > 0 ) { 241 tmpLabel = jQuery( this ).find( 'img' ).attr( 'alt' ); 242 } 243 if ( tmpLabel == '' ) { 244 tmpLabel = jQuery( this ).text(); 245 } 246 247 jQuery( this ) 248 .attr( 'analytics-category', 'Header Links' ) 249 .attr( 'analytics-action', tmpAction ) 250 .attr( 'analytics-label', tmpLabel ); 251 252 jQuery( this ).on( 'click', function(e) { 253 var tmpResult = UMWAnalytics.doClick( this ); 254 /*UMWAnalytics.log( tmpResult );*/ 255 return tmpResult; 256 } ); 257 } ); 258 } 259 260 // Track other home page clicks on new site 261 if ( UMWAnalytics.elementExists( 'body.umw-is-root.home' ) ) { 262 jQuery( '.site-inner a[href!="#"][href][href!=""]' ).each( function() { 263 if ( jQuery( this ).closest( '.flexslider' ).length > 0 ) { 264 return; 265 } 266 267 var tmpAction = ''; 268 if ( jQuery( this ).closest( '.widget' ).find( '.widgettitle' ).length > 0 ) { 269 tmpAction = jQuery( this ).closest( '.widget' ).find( '.widgettitle' ).text(); 270 } else if ( jQuery( this ).closest( '.widget' ).find( '.widget-title' ).length > 0 ) { 271 tmpAction = jQuery( this ).closest( '.widget' ).find( '.widget-title' ).text(); 272 } else { 273 if ( jQuery( this ).closest( '#homepageCTA' ).length > 0 || jQuery( this ).closest( '.homepage-cta' ).length > 0 ) { 274 tmpAction = 'Home Page Call to Action'; 275 } else if ( jQuery( this ).closest( '#impactStatement' ).length > 0 || jQuery( this ).closest( 'impact-statement' ).length > 0 ) { 276 tmpAction = 'Impact Statement'; 277 } else if ( jQuery( this ).closest( '.responsive-tabs' ).length > 0 ) { 278 var tmpAction = jQuery( this ).closest( '.tabcontent' ).prev( '.tabtitle' ).text(); 279 } else if ( jQuery( this ).closest( '.widget-area' ).length > 0 ) { 280 tmpAction = jQuery( this ).closest( '.widget-area' ).attr( 'class' ); 281 tmpAction = tmpAction.replace( '-', ' ' ); 282 tmpAction = tmpAction.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); 283 } else { 284 tmpAction = 'Unidentified Home Page Links'; 285 } 286 } 287 var tmpLabel = jQuery( this ).text(); 288 if ( tmpLabel == '' && jQuery( this ).find( 'img' ).length > 0 ) { 289 if ( jQuery( this ).closest( '.post' ).length > 0 ) { 290 tmpLabel = jQuery( this ).closest( '.post' ).find( 'h2' ).text(); 291 } else { 292 tmpLabel = jQuery( this ).find( 'img' ).attr( 'alt' ); 293 } 294 } 295 296 jQuery( this ) 297 .attr( 'analytics-category', 'Home Page Links' ) 298 .attr( 'analytics-action', tmpAction ) 299 .attr( 'analytics-label', tmpLabel ); 300 301 jQuery( this ).on( 'click', function(e) { 302 var tmpResult = UMWAnalytics.doClick( this ); 303 /*UMWAnalytics.log( tmpResult );*/ 304 return tmpResult; 305 } ); 306 } ); 307 } 308 309 // Track 185r (campus tour) clicks
310 // Works anywhere these campus tour links exist 311 jQuery( 'a[href*="185r.net"], a[href*="askadmissions.net"], a[href*="admissions.umw.edu"]' ).each( function() { 312 var tmpLabel = null; 313 var url = jQuery( this ).attr( 'href' ); 314 315 if ( url.indexOf( 'admission_interviews' ) >= 0 ) { 316 tmpLabel = 'Interviews'; 317 } else if ( url.indexOf( 'register' ) >= 0 && url.indexOf( 'openhouse' ) >= 0 ) { 318 tmpLabel = 'Open Houses and Interviews'; 319 } else if ( url.indexOf( 'shadow_a_student' ) >= 0 ) { 320 tmpLabel = 'Shadow a Student'; 321 } else if ( url.indexOf( 'event_landing' ) >= 0 && url.indexOf( 'id=' ) >= 0 ) { 322 tmpLabel = 'Open Houses and Interviews'; 323 } else if ( url.indexOf( 'event_landing' ) >= 0 ) { 324 tmpLabel = 'Tours and Info Sessions'; 325 } else if ( url.indexOf( 'register' ) >= 0 && url.indexOf( 'id=' ) >= 0 ) { 326 tmpLabel = 'Find my Counselor'; 327 } else if ( url.indexOf( 'moreinfo' ) >= 0 ) { 328 tmpLabel = 'Request for Information'; 329 } 330 331 if ( tmpLabel === null ) { 332 url = url.split('&'); 333 334 for (var i in url) { 335 if (url[i].indexOf('umwpurpose') >= 0) { 336 tmpLabel = url[i].split('=').pop(); 337 } 338 } 339 } 340 341 jQuery( this ) 342 .attr( 'analytics-category', 'Outbound Links' ) 343 .attr( 'analytics-action', 'Campus Tours' ) 344 .attr( 'analytics-label', tmpLabel ); 345 346 jQuery( this ).on( 'click', function(e) { 347 var tmpResult = UMWAnalytics.doClick( this ); 348 /*UMWAnalytics.log( tmpResult );*/ 349 return tmpResult; 350 } ); 351 } ); 352 353 // Track Common App clicks
354 // Works anywhere there are links to the common app 355 jQuery( 'a[href*="commonapp.org"]' ).on( 'click', function(e) { 356 if ( UMWAnalytics.gaExists() ) { 357 ga( 'send', 'event', 'Applications', 'CommonApp' ); 358 ga( '2015UMWProfile.send', 'event', 'Applications', 'CommonApp' ); 359 } 360 return true; 361 } ); 362 363} ); 364 365window.onload = function() { 366 // Track clicks on the home page slideshow 367 // Works on both sites 368 jQuery( '.slides .slide' ).each( function() { 369 var tmpAction = jQuery( this ).find( 'h1, .slide-caption-title' ).text(); 370 var tmpLabel = 'Slide #' + jQuery( this ).index(); 371 372 jQuery( this ).find( 'a' ).each( function() { 373 jQuery( this ) 374 .attr( 'analytics-category', 'Home Page Slideshow' ) 375 .attr( 'analytics-action', tmpAction ) 376 .attr( 'analytics-label', tmpLabel ); 377 } ); 378 379 jQuery( this ).find( 'a' ).on( 'click', function(e) { 380 var tmpResult = UMWAnalytics.doClick( this ); 381 /*UMWAnalytics.log( tmpResult );*/ 382 return tmpResult; 383 } ); 384 } ); 385};
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.