https://coffee-labo.co.jp/wp-content/themes/coffee-swell_child/assets/js/link-tracking.js?ver=1.6.59
1/** 2 * ã·ã§ããå°ç·ã®ã¯ãªãã¯è¨æ¸¬ï¼UTMã®ä»£æ¿ï¼ 3 * 4 * çµç·¯: èªãµã¤ãå ãªã³ã¯ã¨ã·ã§ããå®ãªã³ã¯ã« 5 * utm_source=Google&utm_medium=organic&utm_content=<è¨ç½®å ´æ> 6 * ãä»ãã¦è¨ç½®å ´æå¥ã®ã¯ãªãã¯ãè¦ã¦ããããGA4ã¯ã©ã³ãã£ã³ã°æã«utm_*ãè¦ã¤ãã㨠7 * ã»ãã·ã§ã³ãåã£ã¦ç²å¾å ã䏿¸ããããshop.coffee-labo.co.jp ã¯åªä½å´ã¨åãGA4 8 * ããããã£(307320527)ã§è¨æ¸¬ãã¦ããããããã®ä»ä¸ã¯ãå¥ããããã£ã¸ã®éå®¢è¨æ¸¬ãã« 9 * ãªãããåã«ã»ãã·ã§ã³ãåæãã¦æ¬æ¥ã®ç²å¾å ï¼èªç¶æ¤ç´¢çï¼ãæ¶ãã¦ããã 10 * è¨äºâã·ã§ããâè³¼å ¥ã®å£²ä¸å¸°å±ãããã§éåãã¦ããã 11 * 12 * æ¬ã¹ã¯ãªããã¯UTMã使ããã«åãæ å ±ãGA4ã¤ãã³ãã¨ãã¦éããã»ãã·ã§ã³ã¯åããªãã 13 * ãªã³ã¯å´ã«å±æ§ãè¶³ãå¿ è¦ããªããããè¨ç½®å ´æã¯DOMããå°åºããï¼è¨äº99ä»¶ã 14 * æ¸ãæããã«æ¸ã¾ããããï¼ã 15 * 16 * éä¿¡ããã¤ãã³ãï¼paramsã¯3ã¤ãã³ãå ±éï¼: 17 * select_content : åä¸ãã¡ã¤ã³ã® /shop/ã»/products/ã»/collections/ãæ§Shopifyãã¹ãã 18 * /lp/ é ä¸ï¼ã·ã§ããå°ç·ï¼ 19 * affiliate_click: ASPã»ã¢ã¼ã«å®ã®å¤é¨ã¯ãªãã¯ï¼1.6.18æ°è¨ããããã3é¸ã 20 * Amazon/楽天/Yahooæ ã®å®ã¯ãªãã¯ãã·ã§ããå°ç·ã¨åãåä¿µã§æ¯è¼ããï¼ 21 * outbound_click : ä¸è¨ä»¥å¤ã®å¤é¨ãã¡ã¤ã³å®ã¯ãªãã¯ï¼å¼ç¨å ã»SNSçï¼ 22 * content_type : è¨ç½®å ´æï¼global_menu / info_bar / widget / article_body / footer / otherï¼ 23 * content_id : select_content ã¯é·ç§»å ãã¹ï¼ä¾ /products/fruity-blendï¼ã 24 * å¤é¨2ã¤ãã³ãã¯ãã¹ãè¾¼ã¿ï¼ä¾ af.moshimo.com/af/c/clickï¼100åã¾ã§ 25 * link_url : ååhrefå ¨ä½ãCheckout/accountã®æ©å¯å°ç·ã¯ç½²åpathã»queryãé¤ããåºå®URL 26 * link_text : ãªã³ã¯æè¨ï¼80åã¾ã§ï¼ 27 * link_region : ã¦ã£ã¸ã§ããIDçãè¨ç½®å ´æãããã«ç¹å®ã§ããæåå 28 * 29 * content_type 㨠content_id 㯠GA4 ã®æ¨æºãã£ã¡ã³ã·ã§ã³ contentType / contentId ã« 30 * ãã®ã¾ã¾å ¥ãããç»é²ä¸è¦ãitem_id ã¯ä½¿ããªãï¼ããã¯eã³ãã¼ã¹ã® items é åç¨ã® 31 * äºç´åã§ãã¤ãã³ãåä½ã«ä»ãã¦ã contentId ç¸å½ã®ãã£ã¡ã³ã·ã§ã³ã«ã¯å ¥ããªãï¼ã 32 * link_url / link_text / link_region ã¯ã«ã¹ã¿ã ãã£ã¡ã³ã·ã§ã³ç»é²ãå¿ è¦ã 33 */ 34(function () { 35 'use strict'; 36 37 var LEGACY_SHOP_HOST = 'shop.coffee-labo.co.jp'; 38 var CHECKOUT_HOST = 'checkout.coffee-labo.co.jp'; 39 var SHOPIFY_STORE_ID = '59722727561'; 40 41 /* Checkout URLã«ã¯ç½²åä»ãpath tokenãkey/_glçãå«ã¾ãããGA4ã¸ã¯å°ç·ç¨®å¥ã ãã 42 éãã°ååãªã®ã§ãCheckoutã¨Shopifyã¢ã«ã¦ã³ãã¯åºå®ã®åæç¨URLã¸ç¸®ç´ããã */ 43 function trackedAnalyticsDestination(url) { 44 // Inboxå°ç¨ãã¼ã¸ã¯è³¼å ¥æç¶ãã¨åé¢ãã追å ã¯ã¨ãªã¯è¨æ¸¬ã¸æ¸¡ããªãã 45 if (url.hostname === CHECKOUT_HOST && url.pathname === '/' && url.searchParams.get('clc_chat') === '1') { 46 return { contentId: '/chat', linkUrl: 'https://' + CHECKOUT_HOST + '/?clc_chat=1' }; 47 } 48 var isLegacyCheckout = url.hostname === LEGACY_SHOP_HOST && ( 49 url.pathname === '/checkout' || url.pathname.indexOf('/checkout/') === 0 50 || url.pathname === '/checkouts' || url.pathname.indexOf('/checkouts/') === 0 51 || url.pathname === '/cart/c' || url.pathname.indexOf('/cart/c/') === 0 52 ); 53 var isLegacyAccount = url.hostname === LEGACY_SHOP_HOST && ( 54 url.pathname === '/account' || url.pathname.indexOf('/account/') === 0 55 || url.pathname === '/customer_authentication' || url.pathname.indexOf('/customer_authentication/') === 0 56 ); 57 var shopifyAccountPath = '/' + SHOPIFY_STORE_ID + '/account'; 58 59 if (url.hostname === CHECKOUT_HOST || isLegacyCheckout) { 60 return { 61 contentId: '/checkout', 62 linkUrl: url.origin + '/checkout' 63 }; 64 } 65 66 if ( 67 isLegacyAccount || ( 68 url.hostname === 'shopify.com' 69 && (url.pathname === shopifyAccountPath || url.pathname.indexOf(shopifyAccountPath + '/') === 0) 70 ) 71 ) { 72 return { 73 contentId: '/account', 74 linkUrl: 'https://shopify.com/' + SHOPIFY_STORE_ID + '/account' 75 }; 76 } 77 78 return { 79 contentId: url.pathname || '/', 80 linkUrl: url.href 81 }; 82 } 83 84 /* è¨ç½®å ´æã®å¤å®é ã¯ãå¤å´ã®å¨ããå ã«ãã§ã¯ãªããå ·ä½çãªãã®ããå ã«ãã 85 ãããã¼å ã®ã¦ã£ã¸ã§ãã㯠widget ã§ã¯ãªã global_menu ã¨ãã¦æ°ãããã®ã§ 86 info_bar â global_menu â footer â widget â article_body ã®é ã«è¦ãã */ 87 var REGIONS = [ 88 { type: 'info_bar', selector: '.c-infoBar, .p-infoBar' }, 89 /* PC追å¾ããã¼ãfunctions.phpå´ã®åå¥ãã³ãã©ã¯äºéè¨ä¸ã«ãªãããæ¤å»æ¸ã¿ */ 90 { type: 'labocafe_banner', selector: '#labocafe-footer-banner' }, 91 /* ã¹ããã®è¿½å¾ããã¿ã¼ãã¼ã¯ãããã¼ã¡ãã¥ã¼ã¨åºæ¹ãæ¼ããæ¹ãéãã®ã§åãã¦æ°ãã */ 92 { type: 'fix_bottom_menu', selector: '#fix_bottom_menu, .p-fixBottomMenu' }, 93 { type: 'global_menu', selector: '.l-header, #header, .c-gnav, .p-spMenu, .l-fixHeader' }, 94 { type: 'footer', selector: '.l-footer, #footer' }, 95 /* coffee-labo-commerce ãã©ã°ã¤ã³ï¼WPçµ±åã¹ãã¢ï¼ã®UIï¼1.6.48ï¼ã 96 ã¯ã©ã¹æ¥é è¾ clc- ã¯ãã©ã°ã¤ã³å´ã®è¦ç´ã«ä¾åããï¼å¤æ´æã¯ããã追éï¼ã 97 徿¥ã¯ã¹ãã¢å ã¯ãªãã¯ãå ¨ã¦ other ã«è½ã¡ã¦æå¤§å¢åã«ãªã£ã¦ãã
98 ï¼2026-08-14ã28宿¸¬: other 154ä»¶/select_contentä¸1ä½ï¼ã 99 ãã©ã°ã¤ã³èªèº«ã¯ select_item / add_to_cart çã®eã³ãã¼ã¹ã¤ãã³ããå¥ééã£ã¦ 100 ãããããã§ã®åé¡ã¯ãå°ç·ã¯ãªãã¯ã®çºçå ´æãã©ãã«ã¨ãã¦å ±åãã 101 ï¼åä¸ã¯ãªãã¯ã両系åã«è¼ãã®ã¯ä»æ§ï¼ã.clc-storefront ã¯ãã¼ã¸å ¨ä½ãå ã 102 åãç¿ãªã®ã§ãããå ·ä½çãªé åãå¿ ãå ã«ä¸¦ã¹ã */ 103 { type: 'store_cart', selector: '.clc-cart-dialog, .clc-cart-reminder' }, 104 { type: 'store_chat', selector: '.clc-inbox-floating' }, 105 { type: 'store_quiz', selector: '.clc-quiz-dialog' }, 106 { type: 'product_card', selector: '.clc-product-card' }, 107 { type: 'store_nav', selector: '.clc-shop-header, .clc-announcement, .clc-nav-panel' }, 108 { type: 'store_footer', selector: '.clc-shop-footer' }, 109 { type: 'store_page', selector: '.clc-storefront' }, 110 /* ç®æ¬¡ä¸ã®ã³ã³ãã¯ã3é¸ï¼1.6.20ï¼ãç®æ¬¡ãããã¯å ã«æ¿å ¥ããããã 111 w-beforeToc/widget 㨠article_body ããå ã«å¤å®ãã¦ç¬ç«éè¨ãã */ 112 { type: 'toc_reco', selector: '.toc-reco' }, 113 /* ç£å°ã»ãã«ãã§è¨äºã®èªåCTAï¼functions.php priority 98ï¼ãæ¬ææ«å°¾ã«æ¿å ¥ããã 114 ãã widget/article_body ããå ã«å¤å®ãã¦ç¬ç«éè¨ãã */ 115 { type: 'origin_cta', selector: '.origin-shop-cta' }, 116 { type: 'widget', selector: '.widget, .c-widget, .w-beforeToc, .w-afterToc, .w-cta' }, 117 { type: 'article_body', selector: '.post_content, .c-postContent, .entry-content' } 118 ]; 119 120 function detectRegion(anchor) { 121 for (var i = 0; i < REGIONS.length; i++) { 122 var hit = anchor.closest(REGIONS[i].selector); 123 if (hit) { 124 return { type: REGIONS[i].type, node: hit }; 125 } 126 } 127 return { type: 'other', node: null }; 128 } 129 130 /* ã¦ã£ã¸ã§ããIDãªã©ãåãè¨ç½®å ´æã®ä¸ã§ããã«åºå¥ã§ããæããããæ¾ãã 131 æ§utm_contentã® w-beforeToc_left / c-widget__title-side ç¸å½ã®ç²åº¦ãç¶æããã */ 132 function regionDetail(anchor, region) { 133 if (!region.node) return ''; 134 if (region.node.id) return region.node.id; 135 var cls = region.node.className; 136 if (typeof cls !== 'string') return ''; 137 return cls.trim().split(/\s+/).slice(0, 3).join(' '); 138 } 139 140 /* textContent 㯠<noscript> ã®ä¸èº«ããæååãã¨ãã¦æ¾ããlazyload ãæ¿å ¥ãã 141 <noscript><img ...></noscript> ã®ããã§ link_text ãHTMLã®æçã«ãªãããã 142 è¤è£½ãã noscript/script/style ãå¤ãã¦ããæåãåãã */ 143 function linkText(anchor) { 144 var clone = anchor.cloneNode(true); 145 var junk = clone.querySelectorAll('noscript, script, style'); 146 for (var i = 0; i < junk.length; i++) { 147 junk[i].parentNode.removeChild(junk[i]); 148 } 149 var text = (clone.textContent || '').replace(/\s+/g, ' ').trim(); 150 if (text) return text.slice(0, 80); 151 /* ç»åã ãã®ããã¼ã¯ä»£æ¿ããã¹ãã§ä»£ç¨ãã */ 152 var img = anchor.querySelector('img[alt]'); 153 return img ? ('[img] ' + img.alt).slice(0, 80) : ''; 154 } 155 156 function isCommercePath(pathname) { 157 return pathname === '/shop' || pathname.indexOf('/shop/') === 0 158 || pathname === '/products' || pathname.indexOf('/products/') === 0 159 || pathname === '/collections' || pathname.indexOf('/collections/') === 0; 160 } 161 162 function isTracked(url) { 163 /* æ§ãã¹ãã®æ®åãªã³ã¯ãç§»è¡ç£è¦ã®ããè¨æ¸¬ãç¶ç¶ããã */ 164 if (url.hostname === LEGACY_SHOP_HOST) return true; 165 /* WordPressçµ±åå¾ã®Commerce URLã¨ãã·ã§ããã¸è»¢éããæ§LPãåãå°ç·ã¨ãã¦æ°ããã */ 166 if (url.hostname === location.hostname && (isCommercePath(url.pathname) || url.pathname.indexOf('/lp/') === 0)) return true; 167 /* æ£è¦åå¾ã®Checkoutã»ããªã·ã¼ã»Shopifyã¢ã«ã¦ã³ãå®ãªã³ã¯ããç§»è¡åã¯æ§ãã¹ãå®ã§ 168 select_content ã¨ãã¦è¨ä¸ããã¦ããã·ã§ããå°ç·ãoutbound_click ã¸è½ã¨ããç¶ç¶ããï¼1.6.47ï¼ã */ 169 if (url.hostname === CHECKOUT_HOST) return true; 170 if (url.hostname === 'shopify.com' && url.pathname.indexOf('/' + SHOPIFY_STORE_ID + '/') === 0) return true; 171 return false;
172 } 173 174 /* ã¢ãã£ãªã¨ã¤ãçµè·¯ï¼ASPãªãã¤ã¬ã¯ã¿ã¨ã¢ã¼ã«ç´ãªã³ã¯ï¼ãæ«å°¾ä¸è´ã§å¤å®ããã 175 è¨äºå ã®å®ãªã³ã¯ã¯ af.moshimo.com / px.a8.net / h.accesstrade.net çµç±ã¨ 176 Amazonã»Yahoo!ã·ã§ããã³ã°ç´ãªã³ã¯ï¼2026-08 å®å°èª¿æ»ï¼ã */ 177 var AFFILIATE_HOSTS = [ 178 'moshimo.com', 179 'a8.net', 180 'accesstrade.net', 181 'afi-b.com', 182 'affitch.com', 183 'felmat.net', 184 'rentracks.jp', 185 'valuecommerce.com', 186 'rakuten.co.jp', 187 'r10.to', 188 'amazon.co.jp', 189 'amzn.to', 190 'amzn.asia', 191 'shopping.yahoo.co.jp' 192 ]; 193 194 function isAffiliateHost(hostname) { 195 for (var i = 0; i < AFFILIATE_HOSTS.length; i++) { 196 var domain = AFFILIATE_HOSTS[i]; 197 if (hostname === domain || hostname.slice(-(domain.length + 1)) === '.' + domain) return true; 198 } 199 return false; 200 } 201 202 document.addEventListener('click', function (event) { 203 /* ä»ã®ãã³ãã©ã stopPropagation ãã¦ãæ¾ãããã capture 段éã§åãã */ 204 var target = event.target; 205 if (!target || typeof target.closest !== 'function') return; 206 207 var anchor = target.closest('a[href]'); 208 if (!anchor) return; 209 210 var url; 211 try { 212 url = new URL(anchor.href, location.href); 213 } catch (e) { 214 return; 215 } 216 var eventName = null; 217 var contentId = null; 218 var linkUrl = url.href; 219 if (isTracked(url)) { 220 var destination = trackedAnalyticsDestination(url); 221 eventName = 'select_content'; 222 contentId = destination.contentId; 223 linkUrl = destination.linkUrl; 224 } else if ( 225 (url.protocol === 'http:' || url.protocol === 'https:') && 226 url.hostname && 227 url.hostname !== location.hostname 228 ) { 229 /* å¤é¨ãã¡ã¤ã³å®ãGA4ã®ã¤ãã³ãparamä¸éã«åãã content_id ã¯100åã¾ã§ */ 230 eventName = isAffiliateHost(url.hostname) ? 'affiliate_click' : 'outbound_click'; 231 contentId = (url.hostname + url.pathname).slice(0, 100); 232 } 233 if (!eventName) return; 234 if (typeof window.gtag !== 'function') return; 235 236 var region = detectRegion(anchor); 237 var text = linkText(anchor); 238 239 window.gtag('event', eventName, { 240 content_type: region.type, 241 content_id: contentId, 242 link_url: linkUrl, 243 link_text: text, 244 link_region: regionDetail(anchor, region) 245 }); 246 }, true); 247 248 /* GA4ã®èªåform_submitã¯é信試è¡ãå«ã¿å¾ããContact Form 7ãã¡ã¼ã«éä¿¡æåæã ã 249 çºç«ããã¤ãã³ããããäºæ¥ææç¨ã®generate_leadãå¥ã«éãã */ 250 document.addEventListener('wpcf7mailsent', function (event) { 251 var detail = event.detail || {}; 252 var formId = detail.contactFormId || detail.contact_form_id || ''; 253 window.dataLayer = window.dataLayer || []; 254 if (typeof window.gtag !== 'function') { 255 window.gtag = function () { 256 window.dataLayer.push(arguments); 257 }; 258 } 259 window.gtag('event', 'generate_lead', { 260 content_type: 'contact_form_7', 261 content_id: formId ? String(formId) : 'unknown' 262 }); 263 }); 264 265 /* ç®æ¬¡ä¸ã³ã³ãã¯ã3é¸ã®ééï¼1.6.20ï¼ãtoggle ã¯ãããªã³ã°ããªããã 266 ãã£ããã£æ®µéã§åãããã¼ã¸å ã§æåã«éãã1åã ãéãã */ 267 document.addEventListener('toggle', function (event) { 268 var details = event.target; 269 if (!details || !details.classList || !details.classList.contains('toc-reco')) return; 270 if (!details.open || details.getAttribute('data-reco-opened')) return; 271 details.setAttribute('data-reco-opened', '1'); 272 if (typeof window.gtag !== 'function') return; 273 window.gtag('event', 'toc_reco_open', { 274 content_type: 'toc_reco', 275 content_id: location.pathname 276 }); 277 }, true); 278})();
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.