1// Google Analytics Event tracking codes - jQuery must be installed 2// UNIVERSAL TRACKING CODE EXAMPLE: ga('send', 'event', 'category', 'action', 'opt_label', opt_value, {'nonInteraction': 1}); 3// The codes below are common examples and can be modified, combined or added to as needed 4 5$(document).ready(function(){ 6 7//FIND links ending in .pdf 8 9$('a[href$="pdf"]').each(function() { 10 11// ADD GA tracking code to links 12$(this).attr('onclick', "ga('send', 'event', 'PDF', 'Clicked', jQuery(this).attr('href'), {'nonInteraction': 1});"); 13$(this).attr('target', '_blank'); // OPTIONAL: ADD target blank 14}); 15 16//FIND links to DOCs, XLS, PPT if used 17 18$('a[href$=".doc"], a[href$=".docx"], a[href$=".xls"], a[href$=".xlsx"], a[href$=".ppt"], a[href$=".pptx"]').each(function() { 19 20// ADD GA tracking code to links 21$(this).attr('onclick', "ga('send', 'event', 'Media', 'Clicked', jQuery(this).attr('href'), {'nonInteraction': 1});"); 22}); 23 24//FIND links that start with http 25 26$('a[href^="http"]').each(function() { 27 28// ADD GA tracking code to links 29$(this).attr('onclick', "ga('send', 'event', 'Outbound', 'Clicked', jQuery(this).attr('href'), {'nonInteraction': 1});"); 30$(this).attr('target', '_blank'); // OPTIONAL: ADD target blank 31}); 32 33 34});
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.