1if(typeof SZS == "undefined") SZS = {}; 2 3SZS.IsDev = location.host != "sai-zen-sen.jp" ? true : false; 4SZS.IsLDE = location.hostname == "localhost" ? true : false; 5 6SZS.GA = { 7 init: function() { 8 const Gate = {}; 9 const BaseDirs = [], BasePath = location.pathname, BasePaths = BasePath.split('/'); 10 /**/ Gate['x_path'] = BasePath; /**/ Gate['x_directory'] = ''; 11 for(let l = BasePaths.length - 1, i = 1; i < l; i++) BaseDirs.push(Gate['x_directory' + i] = BasePaths[i]); /**/ Gate['x_directory'] = BaseDirs.join('/').replace(/^\/?/, '/').replace(/\/?$/, '/'); 12 /**/ Gate['x_filename'] = BasePaths.slice(-1)[0]; 13 const Q = (location.search || '').replace(/^\?/, ''); if(Q) Gate['x_querystring'] = Q; 14 const H = (location.hash || '').replace(/^#/, ''); if(H) Gate['x_hash'] = H; 15 Object.keys(Gate).forEach(Key => Gate[Key] = Gate[Key] || ''); 16 if(!SZS.IsLDE) { 17 const TrackingCodes = SZS.IsDev ? { GA4: 'G-JMTFV8G1S4', UA: 'UA-17306372-15' } 18 : { GA4: 'G-X2KHL15R4M', UA: 'UA-17306372-2' }; 19 // GA4 (gtag) 20 (function(S, N) { S.async = 1, S.src = "https://www.googletagmanager.com/gtag/js?id=" + TrackingCodes.GA4; N.parentNode.insertBefore(S, N); })(document.createElement("script"), document.getElementsByTagName("script")[0]); 21 window.dataLayer = window.dataLayer || []; 22 window.gtag = window.gtag || function() { window.dataLayer.push(arguments); }; //////// 23 gtag('js', new Date()); 24 gtag('config', TrackingCodes.GA4, Object.assign({}, Gate, { 25 page_title : document.title, 26 page_location: location.href 27 })); 28 // UA (ga) 29 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 30 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 31 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 32 })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 33 ga("create", TrackingCodes.UA, "auto", { 'allowLinker': true }); 34 ga("require", "linkid", "linkid.js"); 35 ga("send", "pageview"); 36 } 37 SZS.GA.event({ 38 Category: 'Gate', 39 Action: document.title, 40 Label: location.href, 41 Custom: Gate, 42 Log: true, 43 GA4: false, //////// !!!!!!!! //////// 44 UA: true //////// !!!!!!!! //////// 45 }); 46 }, 47 getElementSelector: function(E) { 48 return E.tagName.toLowerCase() + (E.className ? "." + E.className.split(" ")[0] : "") + (E.id ? "#" + E.id : ""); 49 }, 50 getElementPath: function(E) { 51 let Path = ""; 52 while(E && E != document.body) Path = SZS.GA.getElementSelector(E) + " > " + Path, E = E.parentNode; 53 return Path.replace(/ > $/, ""); 54 }, 55 event: function(Par) { 56 if(!Par || !Par.Category || !Par.Action) return; 57 const IDs = ['SaiZenSen'], Delimiter = ': '; 58 const Category = IDs.push(Par.Category) && IDs.join(Delimiter); 59 const Action = IDs.push(Par.Action ) && IDs.join(Delimiter); 60 let Label = Par.Label || ''; 61 if(Par.Element && Par.Element.tagName) { 62 const ElementPath = SZS.GA.getElementPath(Par.Element); 63 if(ElementPath) Label = ElementPath + (Label ? ' - ' + Label : ''); 64 } 65 const Value = (typeof Par.Value == "number" || /^\d(\.\d+)$/.test(Par.Value)) ? Par.Value * 1 : 1; 66 const Custom = (typeof Par.Custom == 'object' && Par.Custom) ? Par.Custom : {}; 67 if(SZS.IsDev || Par.Log) { 68 console.log("[GA:Event] " + Action + (Label ? " [" + Label + "]" : "") + (Value ? " (" + Value + ")" : "")); 69 if(Custom) Object.keys(Custom).forEach(function(Pro) { console.log('â ' + Pro + ': ' + Custom[Pro]); }); 70 } 71 if(!SZS.IsLDE) { 72 // GA4 (gtag) 73 if(Par.GA4) gtag('event', Category, Object.assign(Custom, { 74 "EventAction": Action, 75 "EventLabel" : Label 76 })); 77 // UA (ga) 78 if(Par.UA) ga("send", Object.assign(Custom, { 79 hitType: "event", // Required. 80 eventCategory: Category, // Required. 81 eventAction: Action, // Required. 82 eventLabel: Label, 83 eventValue: Value 84 })); 85 } 86 }, 87 sendEvent: function(Ele, Category, Action, Label, Value, Log) { 88 return SZS.GA.event({ 89 Category: Category, 90 Action: Action, 91 Label: Label, 92 Value: Value, 93 Custom: null, 94 Element: Ele, 95 Log: Log, 96 GA4: true, 97 UA: true 98 }); 99 }, 100 initAnchors: function(Root) { 101 const Anchors = (Root ? Root : document.body).getElementsByTagName("a"); 102 const OriginRE = new RegExp("^" + location.protocol + "\/\/" + location.host + "\/"); 103 for(let i = 0, L = Anchors.length; i < L; i++) { 104 A = Anchors[i]; 105 if(A.SZS_GA) return; 106 A.SZS_GA = "Processed"; 107 if(!OriginRE.test(A.href)) { 108 A.target = "_blank"; 109 if(/^https?:\/\/(twitter\.com\/intent\/tweet\?|www\.facebook\.com\/share.php\?|b\.hatena\.ne\.jp\/entry\/|line\.naver\.jp\/R\/msg\/text\/\?)/.test(A.href)) { 110 A.addEventListener("click", function() { SZS.GA.sendEvent(this, "Social: Share to", this.href.replace(/^https?:\/\//, "").split("/")[0]); }); 111 } else if(/^https?:\/\/(twitter\.com\/)/.test(A.href)) { 112 A.addEventListener("click", function() { SZS.GA.sendEvent(this, "Social: Follow on", this.href.replace(/^https?:\/\//, "")); }); 113 } else { 114 A.addEventListener("click", function() { SZS.GA.sendEvent(this, "Link: Outgo to", this.href.replace(/^https?:\/\//, "")); }); 115 } 116 } 117 } 118 } 119}; 120 121SZS.GA.init(); 122 123(function(fn) { document.readyState == "loading" ? document.addEventListener("DOMContentLoaded", fn) : fn(); })(function() { 124 SZS.GA.initAnchors(); 125});
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.