1 2 3 4document.addEventListener("DOMContentLoaded", function () { 5 document.querySelector(".site-container").addEventListener("click", function (event) { 6 let link = event.target.closest("a"); 7 if (link && link.href) { 8 let url = new URL(link.href); 9 10 // List of all WordPress Media Library allowed file types 11 let fileExtensions = [ 12 ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".tiff", ".svg", ".ico", 13 ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".ods", ".odp", 14 ".mp3", ".m4a", ".ogg", ".wav", 15 ".mp4", ".m4v", ".mov", ".wmv", ".avi", ".mpg", ".ogv", ".3gp", ".3g2" 16 ]; 17 18 let isDownload = fileExtensions.some(ext => url.pathname.toLowerCase().endsWith(ext)); 19 20 if (isDownload) { 21 let fileName = url.pathname.split("/").pop(); // Extract the file name 22 let referringPage = document.location.href; // Get the page where the download happened 23 24 // Send event to Fathom Analytics 25 fathom.trackEvent(`Download: ${fileName}`); 26 27 // (Optional) Small delay to ensure tracking before navigation 28 setTimeout(() => { 29 window.location = link.href; 30 }, 200); 31 32 event.preventDefault(); // Prevents immediate navigation for tracking 33 } 34 } 35 }); 36}); 37 38 39 40 41 42window.addEventListener('load', (event) => { 43 document.querySelectorAll('a').forEach(item => { 44 item.addEventListener('click', event => { 45 let linkUrl = new URL(item.getAttribute('href'), window.location.href); // Handle relative URLs 46 let cleanedUrl = linkUrl.hostname + linkUrl.pathname.replace(/\/$/, ""); // Remove trailing slash 47 let currentHostname = window.location.hostname; 48 49 if (linkUrl.hostname !== currentHostname) { // If the link's hostname is different from the current page's hostname 50 let domainParts = linkUrl.hostname.split('.'); 51 let domainName = domainParts.length > 1 ? domainParts[domainParts.length - 2] : domainParts[0]; 52 53 fathom.trackEvent(`Link: ${cleanedUrl}`); 54 } 55 }); 56 }); 57});
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.