1/** 2 * Loads scripts/features in a deferred manner 3 * 4 * @format 5 * @version 1.7.45 6 */ 7 8// Global variable to prevent delayedScripts from running more than once 9let delayedScriptsInitialized = false; 10 11/** 12 * Constant variables that are referenced within their respective functions 13 * Enter IDs for services you plan to use. 14 */ 15 16// DATA AND ANALYTICS SERVICES 17const googleAnalyticsV4ID = 'G-9YY39VN7Q7'; // Format: 'G-0000000000 (Google Analytics 4 â gtag.js) 18const googleTagManagerID = 'GTM-KF3WBZ'; // Format: GTM-0000000 (Google Tag Manager) 19const googleAdsID = ''; // Format AW-000000000 (Google Ads) 20const googleCallMetricsID = ''; // Format AW-000000000/00000000000000000000 (Google Call Metrics ID, associated with Google Ads) 21const googleCallMetricsPhone1 = ''; // Format 1-000-000-0000 (Google Call Metrics Phone Number) 22const googleCallMetricsPhone2 = ''; // Format 1-000-000-0000 (Google Call Metrics Phone Number) 23const googleLeadConversionID = ''; // Format AW-000000000/00000000000000000000 (Google Lead Conversion ID, associated with Google Ads) 24const googleLeadConversionValue = 1.0; // Decimal value, 1.0 set by default. Update as needed 25const googleLeadConversioncurrency = 'USD'; // Currency, USD set by default. Update as needed 26const facebookPixelID = ''; // Format: 000000000000000 (Facebook pixel tracking) 27const bingConversionID = ''; // Format: 000000000 (Bing conversion tracking) 28 29// CONDITIONAL SERVICES 30const useCickCease = false; // True or false to enable/disable (ClickCease) 31const useGoogleTranslate = false; // True or false to enable/disable (Google Translate) 32 33// CHAT SERVICES 34const ngageChatID = ''; // Format: 0-000-000-000-000-000-000-000 (Ngage live chat) 35const oClarkChatID = ''; // Format: 0000-000-00-0000 (Olark live chat) 36const apexLiveChatID = ''; // Format: String, as in "companyname" (Apex live chat) 37const intakerChatID = ''; // Format: sitename (Intaker live chat) 38const juvoLeadsChatID = ''; // Format: 0000000000 (Juvo Leads live Chat) 39 40// JavaScript code to execute after the DOM is ready 41document.addEventListener('DOMContentLoaded', function (event) { 42 // Load script(s) after the user scrolls, moves the mouse, or touches the screen 43 document.addEventListener('scroll', delayedScripts); 44 document.addEventListener('mousemove', delayedScripts); 45 document.addEventListener('touchstart', delayedScripts); 46 47 setTimeout(function () { 48 delayedScripts(); 49 }, 4000); 50}); 51 52// Run scripts when user interacts with the page 53function delayedScripts(event) { 54 // Trigger this function only once 55 if (delayedScriptsInitialized) return; 56 57 setupGoogleAnalytics(); 58 59 // Execute functions based on the IDs above 60 if (googleTagManagerID) setupGoogleTagManager(window, document, 'script', 'dataLayer', googleTagManagerID); 61 if (facebookPixelID) setupPixel(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js'); 62 if (bingConversionID) setupBingConversion(window, document, 'script', '//bat.bing.com/bat.js', 'uetq'); 63 if (ngageChatID) setupNgageChat('https://messenger.ngageics.com/ilnksrvr.aspx?websiteid=', document, 'script', ngageChatID); 64 if (oClarkChatID) setupOlarkChat(window, document, 'static.olark.com/jsclient/loader.js'); 65 if (apexLiveChatID) setupApexChat(); 66 if (intakerChatID) setupIntaker(window, document, 'script', 'Intaker', intakerChatID); 67 if (juvoLeadsChatID) setupJuvoLeads(); 68 if (useCickCease) setupClickease(); 69 if (useGoogleTranslate) setupGoogleTranslate(); 70 71 // Set variable to true to prevent delayedScripts from rerunning 72 delayedScriptsInitialized = true; 73} 74 75// Initializes Google Analytics 76function setupGoogleAnalytics() { 77 // Return if googleAnalyticsV4ID is not set 78 if (!googleAnalyticsV4ID) { 79 console.log('Analytics variable is not set!'); 80 return; 81 } 82 83 console.log('Setup analytics with ID ' + googleAnalyticsV4ID); 84 85 // Create the script 86 const script = document.createElement('script'); 87 script.type = 'text/javascript'; 88 script.onload = () => { 89 window.dataLayer = window.dataLayer || []; 90 function gtag() { 91 dataLayer.push(arguments); 92 } 93 gtag('js', new Date()); 94 if (googleAnalyticsV4ID) gtag('config', googleAnalyticsV4ID);
95 if (googleAdsID) gtag('config', googleAdsID); 96 if (googleCallMetricsID && googleCallMetricsPhone1) 97 gtag('config', googleCallMetricsID, { 98 phone_conversion_number: googleCallMetricsPhone1 99 }); 100 if (googleCallMetricsID && googleCallMetricsPhone2) 101 gtag('config', googleCallMetricsID, { 102 phone_conversion_number: googleCallMetricsPhone2 103 }); 104 if (googleLeadConversionID) 105 gtag('event', 'conversion', { 106 send_to: googleLeadConversionID, 107 value: googleLeadConversionValue, 108 currency: googleLeadConversioncurrency 109 }); 110 document.querySelectorAll('a[href^="tel:"]').forEach(link => { 111 link.addEventListener('click', function () { 112 if (typeof gtag === 'function') { 113 gtag('event', 'phone_call_click', { 114 phone_number: this.href.replace('tel:', ''), 115 page_url: window.location.href 116 }); 117 console.log('gtag phone_call_click event fired'); 118 } 119 }); 120 }); 121 }; 122 123 // Set the source of the script based on the variables above 124 script.src = 'https://www.googletagmanager.com/gtag/js?id=' + googleAnalyticsV4ID; 125 126 //Set attribute 127 script.defer = true; 128 129 // Append the script to the body of the document 130 document.getElementsByTagName('body')[0].appendChild(script); 131} 132 133// Load chat feature late 134function setupNgageChat(ng, a, g, e) { 135 console.log('Setup Ngage with ID ' + ngageChatID); 136 137 var l = document.createElement(g); 138 l.async = 1; 139 l.src = ng + e; 140 var c = a.getElementsByTagName(g)[0]; 141 c.parentNode.insertBefore(l, c); 142} 143 144// Load Olark chat late 145function setupOlarkChat(o, l, a, r, k, y) { 146 console.log('Setup Olark with ID ' + oClarkChatID); 147 148 r = 'script'; 149 y = l.createElement(r); 150 r = l.getElementsByTagName(r)[0]; 151 y.async = 1; 152 y.src = '//' + a; 153 r.parentNode.insertBefore(y, r); 154 y = o.olark = function () { 155 k.s.push(arguments); 156 k.t.push(+new Date()); 157 }; 158 y.extend = function (i, j) { 159 y('extend', i, j); 160 }; 161 y.identify = function (i) { 162 y('identify', (k.i = i)); 163 }; 164 y.configure = function (i, j) { 165 y('configure', i, j); 166 k.c[i] = j; 167 }; 168 k = y._ = { s: [], t: [+new Date()], c: {}, l: a }; 169 170 olark.identify(oClarkChatID); 171} 172 173// Load Google Tag Manager late 174function setupGoogleTagManager(w, d, s, l, i) { 175 console.log('Setup Google Tag Manager ' + i); 176 177 // Head script 178 w[l] = w[l] || []; 179 w[l].push({ 180 'gtm.start': new Date().getTime(), 181 event: 'gtm.js' 182 }); 183 var f = d.getElementsByTagName(s)[0], 184 j = d.createElement(s), 185 dl = l != 'dataLayer' ? '&l=' + l : ''; 186 j.async = true; 187 j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; 188 f.parentNode.insertBefore(j, f); 189 190 // Body script 191 const script = document.createElement('noscript'); 192 const iframe = document.createElement('iframe'); 193 194 iframe.src = 'https://www.googletagmanager.com/ns.html?id=' + i; 195 iframe.height = 0; 196 iframe.width = 0; 197 iframe.style.display = 'none'; 198 iframe.style.visibility = 'hidden'; 199 200 // Move elements to correct locations 201 script.appendChild(iframe); 202 document.getElementsByTagName('body')[0].prepend(script); 203} 204 205// Load Pixel script late 206function setupPixel(f, b, e, v, n, t, s) { 207 console.log('Setup Pixel ' + facebookPixelID); 208 209 if (f.fbq) return; 210 n = f.fbq = function () { 211 n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments); 212 }; 213 if (!f._fbq) f._fbq = n; 214 n.push = n; 215 n.loaded = !0; 216 n.version = '2.0'; 217 n.queue = []; 218 t = b.createElement(e); 219 t.async = !0; 220 t.src = v; 221 s = b.getElementsByTagName(e)[0]; 222 s.parentNode.insertBefore(t, s); 223 224 fbq( 225 'init', 226 facebookPixelID, 227 {}, 228 { 229 agent: 'wordpress-5.7.1-3.0.5' 230 } 231 ); 232 233 fbq('track', 'PageView', []); 234 235 const noScript = document.createElement('noscript'); 236 noScript.innerHTML += '<img height="1" width="1" style="display:none" alt="fbpx"src="https://www.facebook.com/tr?id=' + facebookPixelID + '&ev=PageView&noscript=1" />'; 237 238 // Move elements to correct locations 239 document.getElementsByTagName('head')[0].append(noScript); 240} 241 242// Load Bing Conversion script late 243function setupBingConversion(w, d, t, r, u) { 244 console.log('Setup Bing Conversion ' + bingConversionID); 245 246 var f, n, i; 247 (w[u] = w[u] || []), 248 (f = function () { 249 var o = { ti: bingConversionID }; 250 (o.q = w[u]), (w[u] = new UET(o)), w[u].push('pageLoad'); 251 }), 252 (n = d.createElement(t)), 253 (n.src = r), 254 (n.async = 1), 255 (n.onload = n.onreadystatechange = 256 function () { 257 var s = this.readyState; 258 (s && s !== 'loaded' && s !== 'complete') || (f(), (n.onload = n.onreadystatechange = null)); 259 }), 260 (i = d.getElementsByTagName(t)[0]), 261 i.parentNode.insertBefore(n, i); 262} 263 264// Load Apex Chat 265function setupApexChat() { 266 console.log('Setup Apex Chat with ID ' + apexLiveChatID); 267 268 const script = document.createElement('script'); 269 script.src = '//www.apex.live/scripts/invitation.ashx?company=' + apexLiveChatID; 270 script.async = true; 271 272 // Add script to body 273 document.getElementsByTagName('body')[0].appendChild(script); 274} 275 276// Load Intake chat service late 277function setupIntaker(w, d, s, v, odl) { 278 console.log('Intaker Loaded'); 279 280 (w[v] = w[v] || {})['odl'] = odl; 281 var f = d.getElementsByTagName(s)[0],
282 j = d.createElement(s); 283 j.async = true; 284 j.src = 'https://intaker.azureedge.net/widget/chat.min.js'; 285 f.parentNode.insertBefore(j, f); 286} 287 288/** 289 * Load Google Translate script late 290 * 291 * This function does not work with wordpress google translate plugin 292 * This should only be used for custom google translate install. Example on https://www.thorntaxlaw.com/ 293 * 294 * If there is google tracking, the googleAnalyticsID should be filled in, or updated accordingly 295 */ 296function setupGoogleTranslate() { 297 console.log('Setup Google Translate'); 298 299 // Create script to add to the footer 300 const script = document.createElement('script'); 301 script.src = 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'; 302 script.async = true; 303 304 // Create script for google translate init function to add to the footer 305 const script2 = document.createElement('script'); 306 script2.innerHTML = function googleTranslateElementInit() { 307 new google.translate.TranslateElement( 308 { 309 pageLanguage: 'en', 310 includedLanguages: 'cy,de,es,fr,hi,it,nl,no,ru,tr,zh-CN', 311 layout: google.translate.TranslateElement.InlineLayout.SIMPLE, 312 gaTrack: !0, 313 gaId: googleAnalyticsID || '' 314 }, 315 'google_translate_element' 316 ); 317 }; 318 script2.async = true; 319 320 // Add google translate script to the footer, followed by the init function 321 document.getElementsByTagName('footer')[0].appendChild(script); 322 document.getElementsByTagName('footer')[0].appendChild(script2); 323} 324 325/** 326 * Load Clickease late 327 * 328 * Does not require any global variables to be set. 329 * Just uncomment the function call to use 330 * */ 331function setupClickease() { 332 console.log('Setup Clickease'); 333 334 // Create the script element 335 var scriptElement = document.createElement('script'); 336 scriptElement.async = true; 337 scriptElement.type = 'text/javascript'; 338 339 // Set the source of the script element 340 var target = 'https://www.clickcease.com/monitor/stat.js'; 341 scriptElement.src = target; 342 343 // Append the script element to the head of the document 344 var headElement = document.head || document.getElementsByTagName('head')[0]; 345 headElement.appendChild(scriptElement); 346 347 // Create the noscript element 348 var noscriptElement = document.createElement('noscript'); 349 350 // Create the anchor element and set its href attribute 351 var anchorElement = document.createElement('a'); 352 anchorElement.href = 'https://www.clickcease.com'; 353 354 // Create the image element, set its src and alt attributes, and append it to the anchor element 355 var imageElement = document.createElement('img'); 356 imageElement.src = 'https://monitor.clickcease.com/stats/stats.aspx'; 357 imageElement.alt = 'Click Fraud Protection'; 358 anchorElement.appendChild(imageElement); 359 360 // Append the anchor element to the noscript element 361 noscriptElement.appendChild(anchorElement); 362 363 // Append the noscript element to the body of the document 364 document.body.appendChild(noscriptElement); 365} 366 367// Load Juvo Leads Tag script late 368function setupJuvoLeads() { 369 console.log('Setup Juvoleads'); 370 371 const script = document.createElement('script'); 372 script.src = 'https://cdn.juvoleads.com/tag/' + juvoLeadsChatID + '.js?v=' + Math.floor(Math.random() * 9999999999); 373 script.async = true; 374 375 // Add script to body 376 document.getElementsByTagName('footer')[0].appendChild(script); 377}
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.