1/** 2 * BSX Video Tracker â Frontend tracking script 3 * 4 * Tracks actual video play events and pageviews. 5 */ 6(function () { 7 'use strict'; 8 9 if (typeof bsxVT === 'undefined') { 10 return; 11 } 12 13 // Strip query params, fragments, and ensure trailing slash for clean grouping. 14 function cleanUrl(url) { 15 try { 16 var u = new URL(url); 17 var path = u.origin + u.pathname; 18 // Ensure trailing slash for page URLs (not for files like .mp4). 19 if (path.indexOf('.') === -1 || path.lastIndexOf('/') > path.lastIndexOf('.')) { 20 if (path.charAt(path.length - 1) !== '/') path += '/'; 21 } 22 return path; 23 } catch (e) { 24 return url; 25 } 26 } 27 28 function sendBeacon(action, data) { 29 data.action = action; 30 var body = new URLSearchParams(data).toString(); 31 32 if (navigator.sendBeacon) { 33 navigator.sendBeacon(bsxVT.ajaxUrl, new Blob([body], { type: 'application/x-www-form-urlencoded' })); 34 } else { 35 fetch(bsxVT.ajaxUrl, { 36 method: 'POST', 37 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 38 body: body, 39 keepalive: true, 40 }); 41 } 42 } 43 44 function getVideoSrc(video) { 45 if (video.currentSrc) return video.currentSrc; 46 if (video.src) return video.src; 47 var source = video.querySelector('source'); 48 return source ? source.src : ''; 49 } 50 51 /* âââ Track pageview âââ */ 52 53 var pageUrl = cleanUrl(window.location.href); 54 55 sendBeacon('bsx_vt_track_pageview', { 56 page_url: pageUrl, 57 page_title: document.title, 58 }); 59 60 /* âââ Track video plays (one per video per pageload) âââ */ 61 62 var tracked = {}; 63 64 // The "play" event does not bubble, but it CAN be captured. 65 // Capture phase on document catches every <video> play on the page, 66 // including dynamically added videos â no MutationObserver needed. 67 document.addEventListener('play', function (e) { 68 if (e.target.tagName !== 'VIDEO') return; 69 70 var src = getVideoSrc(e.target); 71 if (!src || tracked[src]) return; 72 tracked[src] = true; 73 74 sendBeacon('bsx_vt_track_click', { 75 video_id: src, 76 page_url: pageUrl, 77 page_title: document.title, 78 }); 79 }, true); 80 81})();
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.