1(function(){ 2 class SessionTracker { 3 constructor() { 4 // ãã©ã¡ã¼ã¿ã¯&ã§ç¹ããæååã«å¤æ´ 5 this.routes = [ 6 { path: '/contact/', params: 'request_materials-1=1' }, 7 { path: '/contact/', params: 'price-1=1' }, 8 { path: '/taiken/', params: 'taiken-1=1' }, 9 { path: '/request/', params: 'request_materials-1=1' }, 10 { path: '/request/', params: 'price-1=1' }, 11 { path: '/request/', params: 'soudan-1=1' }, 12 { path: '/online/request/', params: 'request_materials-1=1' }, 13 { path: '/online/request/', params: 'price-1=1' }, 14 { path: '/try-online/request/', params: 'request_materials-1=1' }, 15 { path: '/try-online/request/', params: 'price-1=1' }, 16 { path: '/try-online/request/', params: 'taiken-1=1' }, 17 { path: '/toiawase/kyoin/', params: 'kyoin_request_materials-1=1' }, 18 { path: '/toiawase/', params: 'request_materials-1=1' }, 19 { path: '/toiawase/', params: 'price-1=1' }, 20 { path: '/reserve/', params: 'event_type=1&taikendan=1' }, 21 { path: '/reserve/', params: 'event_type=2&opencampus=1' }, 22 { path: '/reserve/', params: 'event_type=3&soudankai=1' }, 23 ]; 24 this.url = new URL(window.location.href); 25 this.path = this.url.pathname; 26 this.params = this.url.searchParams; 27 } 28 29 track() { 30 this.storeReferrer(); 31 this.storeCategoryType(); 32 this.storeMediaType(); 33 } 34 35 storeReferrer() { 36 const sourceUrl = this.params.get('source_url'); 37 if(sourceUrl) { 38 sessionStorage.setItem('referrer', decodeURIComponent(sourceUrl)); 39 } else { 40 const referrer = document.referrer || ''; 41 if (referrer) { 42 sessionStorage.setItem('referrer', referrer); 43 } 44 } 45 } 46 47 storeCategoryType() { 48 for (const route of this.routes) { 49 if (this.path === route.path && this.checkParams(route.params)) { 50 sessionStorage.setItem('category_type', route.params); 51 break; 52 } 53 } 54 } 55 56 // å ¨ã¦ã®ãã©ã¡ã¼ã¿ãæã£ã¦ããå ´åã®ã¿true 57 checkParams(paramsString) { 58 if (!paramsString) return false; 59 60 const paramsArray = paramsString.split('&'); // ['event_type=2', 'opencampus=1'] 61 62 return paramsArray.every(param => { 63 const [key, value] = param.split('='); // key: 'event_type', value: '2' 64 return this.params.get(key) === value; 65 }); 66 } 67 68 storeMediaType() { 69 let mediaType; 70 71 try { 72 const queryParamsStr = sessionStorage.getItem('queryParams'); 73 if (queryParamsStr) { 74 const queryParams = JSON.parse(queryParamsStr); 75 if (queryParams.utm_media) { 76 mediaType = queryParams.utm_media.toLowerCase(); 77 } 78 } 79 } catch (e) { 80 console.warn('queryParams ã® JSON ãã¼ã¹ã«å¤±æãã¾ãã', e); 81 } 82 83 if (!mediaType) { 84 const utmMedia = this.params.get('utm_media'); 85 mediaType = utmMedia ? utmMedia.toLowerCase() : 'organic'; 86 } 87 88 sessionStorage.setItem('media_type', mediaType); 89 } 90 } 91 92 (function () { 93 window.SessionTracker = new SessionTracker(); 94 })(); 95})();
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.