1// Google consent script 2 3 (function () { 4 var CONSENT_COOKIE = "phos_consent_v2"; 5 var HIDE_UNTIL_COOKIE = "phos_cookie_hide_until"; 6 var CONSENT_DAYS = 365; 7 var HIDE_DAYS = 1; 8 9 function setCookie(name, value, days) { 10 var d = new Date(); 11 d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000)); 12 13 document.cookie = 14 name + "=" + encodeURIComponent(value) + 15 ";expires=" + d.toUTCString() + 16 ";path=/;SameSite=Lax"; 17 } 18 19 function getCookie(name) { 20 var cookies = document.cookie ? document.cookie.split(";") : []; 21 22 for (var i = 0; i < cookies.length; i++) { 23 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 24 25 if (c.indexOf(name + "=") === 0) { 26 return decodeURIComponent(c.substring(name.length + 1)); 27 } 28 } 29 30 return null; 31 } 32 33 function deleteCookie(name) { 34 document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;SameSite=Lax"; 35 } 36 37 function parseJson(value) { 38 if (!value) return null; 39 40 try { 41 return JSON.parse(value); 42 } catch (e) { 43 return null; 44 } 45 } 46 47 function getSavedConsent() { 48 return parseJson(getCookie(CONSENT_COOKIE)); 49 } 50 51 function getHideUntil() { 52 var value = getCookie(HIDE_UNTIL_COOKIE); 53 54 if (!value) return 0; 55 56 var parsed = parseInt(value, 10); 57 58 if (isNaN(parsed)) return 0; 59 60 return parsed; 61 } 62 63 function getElements() { 64 return { 65 overlay: document.getElementById("phosCookieOverlay"), 66 customisePanel: document.getElementById("phosCookieCustomise"), 67 settings: document.getElementById("phosCookieSettings"), 68 69 customise: document.getElementById("phosCookieCustomize"), 70 deny: document.getElementById("phosCookieDeny"), 71 allowAll: document.getElementById("phosCookieAllowAll"), 72 allowSelection: document.getElementById("phosCookieAllowSelection"), 73 74 functional: document.getElementById("phosCookieFunctional"), 75 analytics: document.getElementById("phosCookieAnalytics"), 76 marketing: document.getElementById("phosCookieMarketing") 77 }; 78 } 79 80 function shouldShowBanner() { 81 var savedConsent = getSavedConsent(); 82 83 if (savedConsent && savedConsent.saved === true) { 84 return false; 85 } 86 87 var hideUntil = getHideUntil(); 88 89 if (hideUntil && new Date().getTime() < hideUntil) { 90 return false; 91 } 92 93 return true; 94 } 95 96 function showBanner() { 97 var el = getElements(); 98 99 if (el.overlay) { 100 el.overlay.style.display = "flex"; 101 } 102 103 if (document.body) { 104 document.body.classList.add("phos-cookie-locked"); 105 } 106 } 107 108 function hideBanner() { 109 var el = getElements(); 110 111 if (el.overlay) { 112 el.overlay.style.display = "none"; 113 } 114 115 if (document.body) { 116 document.body.classList.remove("phos-cookie-locked"); 117 } 118 } 119 120 function showSettingsButton() { 121 var el = getElements(); 122 123 if (el.settings) { 124 el.settings.style.display = "block"; 125 } 126 } 127 128 function hideSettingsButton() { 129 var el = getElements(); 130 131 if (el.settings) { 132 el.settings.style.display = "none"; 133 } 134 } 135 136 function isCustomiseOpen() { 137 var el = getElements(); 138 139 return !!( 140 el.customisePanel && 141 el.customisePanel.classList.contains("phos-cookie-customise--open") 142 ); 143 } 144 145 function showCustomiseOptions() { 146 var el = getElements(); 147 148 if (el.customisePanel) { 149 el.customisePanel.hidden = false; 150 el.customisePanel.classList.add("phos-cookie-customise--open"); 151 } 152 153 if (el.customise) { 154 el.customise.setAttribute("aria-expanded", "true"); 155 el.customise.textContent = "Hide"; 156 } 157 } 158 159 function hideCustomiseOptions() { 160 var el = getElements(); 161 162 if (el.customisePanel) { 163 el.customisePanel.classList.remove("phos-cookie-customise--open"); 164 el.customisePanel.hidden = true; 165 } 166 167 if (el.customise) { 168 el.customise.setAttribute("aria-expanded", "false"); 169 el.customise.textContent = "Customize"; 170 } 171 } 172 173 function toggleCustomiseOptions() { 174 if (isCustomiseOpen()) { 175 hideCustomiseOptions(); 176 } else { 177 showCustomiseOptions(); 178 } 179 } 180 181 function updateGoogleConsent(consent) { 182 var update = { 183 "ad_storage": "denied", 184 "ad_user_data": "denied", 185 "ad_personalization": "denied", 186 "analytics_storage": "denied", 187 "functionality_storage": "denied", 188 "personalization_storage": "denied", 189 "security_storage": "granted" 190 }; 191 192 if (consent.analytics === true) { 193 update.analytics_storage = "granted"; 194 } 195 196 if (consent.functional === true) { 197 update.functionality_storage = "granted"; 198 update.personalization_storage = "granted"; 199 } 200 201 if (consent.marketing === true) { 202 update.ad_storage = "granted"; 203 update.ad_user_data = "granted"; 204 update.ad_personalization = "granted"; 205 } 206 207 window.dataLayer = window.dataLayer || []; 208 209 if (typeof window.gtag === "function") { 210 window.gtag("consent", "update", update); 211 } else { 212 window.dataLayer.push({ 213 event: "consent_update_fallback", 214 consent_update: update 215 }); 216 } 217 218 window.dataLayer.push({ 219 event: "consent_updated", 220 consent_necessary: true, 221 consent_functional: consent.functional === true, 222 consent_analytics: consent.analytics === true, 223 consent_marketing: consent.marketing === true 224 }); 225 } 226 227 function dispatchConsentEvent(saved) { 228 try { 229 document.dispatchEvent(new CustomEvent("phos_consent_updated", { 230 detail: saved 231 })); 232 } catch (e) { 233 var evt = document.createEvent("CustomEvent"); 234 evt.initCustomEvent("phos_consent_updated", true, true, saved); 235 document.dispatchEvent(evt); 236 } 237 } 238 239 function saveConsent(consent, permanent) { 240 var saved = { 241 saved: permanent === true, 242 necessary: true, 243 functional: consent.functional === true, 244 analytics: consent.analytics === true, 245 marketing: consent.marketing === true, 246 date: new Date().toISOString() 247 }; 248 249 if (permanent === true) {
250 setCookie(CONSENT_COOKIE, JSON.stringify(saved), CONSENT_DAYS); 251 deleteCookie(HIDE_UNTIL_COOKIE); 252 } 253 254 updateGoogleConsent(saved); 255 dispatchConsentEvent(saved); 256 257 hideBanner(); 258 hideCustomiseOptions(); 259 showSettingsButton(); 260 } 261 262 function rejectAllForOneDay() { 263 var tomorrow = new Date().getTime() + (HIDE_DAYS * 24 * 60 * 60 * 1000); 264 265 setCookie(HIDE_UNTIL_COOKIE, String(tomorrow), HIDE_DAYS); 266 267 saveConsent({ 268 functional: false, 269 analytics: false, 270 marketing: false 271 }, false); 272 } 273 274 function acceptAll() { 275 var el = getElements(); 276 277 if (el.functional) el.functional.checked = true; 278 if (el.analytics) el.analytics.checked = true; 279 if (el.marketing) el.marketing.checked = true; 280 281 saveConsent({ 282 functional: true, 283 analytics: true, 284 marketing: true 285 }, true); 286 } 287 288 function saveSelection() { 289 var el = getElements(); 290 291 saveConsent({ 292 functional: el.functional ? el.functional.checked === true : false, 293 analytics: el.analytics ? el.analytics.checked === true : false, 294 marketing: el.marketing ? el.marketing.checked === true : false 295 }, true); 296 } 297 298 function populateFromSavedConsent() { 299 var saved = getSavedConsent(); 300 var el = getElements(); 301 302 if (!saved) return; 303 304 if (el.functional) el.functional.checked = saved.functional === true; 305 if (el.analytics) el.analytics.checked = saved.analytics === true; 306 if (el.marketing) el.marketing.checked = saved.marketing === true; 307 308 updateGoogleConsent(saved); 309 } 310 311 function bindButtons() { 312 var el = getElements(); 313 314 if (el.customise) { 315 el.customise.setAttribute("aria-expanded", "false"); 316 317 el.customise.onclick = function () { 318 toggleCustomiseOptions(); 319 }; 320 } 321 322 if (el.deny) { 323 el.deny.onclick = function () { 324 rejectAllForOneDay(); 325 }; 326 } 327 328 if (el.allowAll) { 329 el.allowAll.onclick = function () { 330 acceptAll(); 331 }; 332 } 333 334 if (el.allowSelection) { 335 el.allowSelection.onclick = function () { 336 saveSelection(); 337 }; 338 } 339 340 if (el.settings) { 341 el.settings.onclick = function () { 342 populateFromSavedConsent(); 343 hideCustomiseOptions(); 344 showBanner(); 345 }; 346 } 347 } 348 349 function initCookieConsent() { 350 bindButtons(); 351 populateFromSavedConsent(); 352 hideCustomiseOptions(); 353 354 if (shouldShowBanner()) { 355 showBanner(); 356 hideSettingsButton(); 357 } else { 358 hideBanner(); 359 showSettingsButton(); 360 } 361 } 362 363 if (document.readyState === "loading") { 364 document.addEventListener("DOMContentLoaded", initCookieConsent); 365 } else { 366 initCookieConsent(); 367 } 368 })(); 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384// OVER ARCHING PAGES 385// Product related pages GTM product_view event tracking with consent management 386(function () { 387 var hasPushedInitialProductView = false; 388 389 function isProductPage() { 390 var path = window.location.pathname.toLowerCase(); 391 392 return ( 393 path === "/products" || 394 path === "/products/" || 395 path === "/products-view" || 396 path === "/products-view/" || 397 path.indexOf("/products/") === 0 398 ); 399 } 400 401 function getProductName() { 402 var h1 = document.querySelector("h1"); 403 404 if (h1 && h1.innerText) { 405 return h1.innerText.trim(); 406 } 407 408 var title = document.title || ""; 409 return title.replace("[PHOS] -", "").trim(); 410 } 411 412 function getConsentCookie() { 413 var name = "phos_consent_v2="; 414 var cookies = document.cookie ? document.cookie.split(";") : []; 415 416 for (var i = 0; i < cookies.length; i++) { 417 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 418 419 if (c.indexOf(name) === 0) { 420 try { 421 return JSON.parse(decodeURIComponent(c.substring(name.length))); 422 } catch (e) { 423 return null; 424 } 425 } 426 } 427 428 return null; 429 } 430 431 function hasAnalyticsConsent(consent) { 432 return consent && consent.analytics === true; 433 } 434 435 function pushProductView(source) { 436 if (!isProductPage()) { 437 console.log("GTM product_view not pushed: not a product page", window.location.pathname); 438 return; 439 } 440 441 window.dataLayer = window.dataLayer || []; 442 443 var eventData = { 444 event: "product-view", 445 event_source: source || "page_load", 446 page_url: window.location.href, 447 page_path: window.location.pathname, 448 page_title: document.title, 449 product_name: getProductName() 450 }; 451 452 window.dataLayer.push(eventData); 453
454 console.log("GTM product_view pushed:", eventData); 455 } 456 457 function pushInitialProductView() { 458 if (hasPushedInitialProductView) return; 459 460 var consent = getConsentCookie(); 461 462 if (!hasAnalyticsConsent(consent)) { 463 console.log("GTM product_view not pushed: analytics consent not granted"); 464 return; 465 } 466 467 hasPushedInitialProductView = true; 468 pushProductView("page_load"); 469 } 470 471 function pushProductViewAfterConsent(e) { 472 if (hasPushedInitialProductView) return; 473 474 var detail = e && e.detail ? e.detail : null; 475 var consent = detail || getConsentCookie(); 476 477 if (!hasAnalyticsConsent(consent)) return; 478 479 hasPushedInitialProductView = true; 480 pushProductView("consent_granted"); 481 } 482 483 if (document.readyState === "loading") { 484 document.addEventListener("DOMContentLoaded", pushInitialProductView); 485 } else { 486 pushInitialProductView(); 487 } 488 489 document.addEventListener("phos_consent_updated", pushProductViewAfterConsent); 490})(); 491 492 493 document.addEventListener("DOMContentLoaded", function() { 494 // Find all links with href="/products/all & change it to /products-view" 495 var links = document.querySelectorAll('a[href="/products/all"]'); 496 497 links.forEach(function(link) { 498 link.setAttribute("href", "/products-view"); 499 }); 500}); 501 502 503// Finishes pages GTM event tracking with consent management 504 505(function () { 506 var hasPushedInitialFinishesView = false; 507 508 function isFinishesPage() { 509 var path = window.location.pathname.toLowerCase(); 510 511 return ( 512 path === "/finishes" || 513 path === "/finishes/" || 514 path === "/finishes-view" || 515 path === "/finishes-view/" || 516 path.indexOf("/finishes/") === 0 517 ); 518 } 519 520 function getFinishesName() { 521 var h1 = document.querySelector("h1"); 522 523 if (h1 && h1.innerText) { 524 return h1.innerText.trim(); 525 } 526 527 var title = document.title || ""; 528 return title.replace("[PHOS] -", "").trim(); 529 } 530 531 function getConsentCookie() { 532 var name = "phos_consent_v2="; 533 var cookies = document.cookie ? document.cookie.split(";") : []; 534 535 for (var i = 0; i < cookies.length; i++) { 536 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 537 538 if (c.indexOf(name) === 0) { 539 try { 540 return JSON.parse(decodeURIComponent(c.substring(name.length))); 541 } catch (e) { 542 return null; 543 } 544 } 545 } 546 547 return null; 548 } 549 550 function hasAnalyticsConsent(consent) { 551 return consent && consent.analytics === true; 552 } 553 554 function pushFinishesView(source) { 555 if (!isFinishesPage()) { 556 console.log("GTM finishes-view not pushed: not a finishes page", window.location.pathname); 557 return; 558 } 559 560 window.dataLayer = window.dataLayer || []; 561 562 var eventData = { 563 event: "finishes-view", 564 event_source: source || "page_load", 565 page_url: window.location.href, 566 page_path: window.location.pathname, 567 page_title: document.title, 568 finishes_name: getFinishesName() 569 }; 570 571 window.dataLayer.push(eventData); 572 573 console.log("GTM finishes-view pushed:", eventData); 574 } 575 576 function pushInitialFinishesView() { 577 if (hasPushedInitialFinishesView) return; 578 579 var consent = getConsentCookie(); 580 581 if (!hasAnalyticsConsent(consent)) { 582 console.log("GTM finishes-view not pushed: analytics consent not granted"); 583 return; 584 } 585 586 hasPushedInitialFinishesView = true; 587 pushFinishesView("page_load"); 588 } 589 590 function pushFinishesViewAfterConsent(e) { 591 if (hasPushedInitialFinishesView) return; 592 593 var detail = e && e.detail ? e.detail : null; 594 var consent = detail || getConsentCookie(); 595 596 if (!hasAnalyticsConsent(consent)) return; 597 598 hasPushedInitialFinishesView = true; 599 pushFinishesView("consent_granted"); 600 } 601 602 if (document.readyState === "loading") { 603 document.addEventListener("DOMContentLoaded", pushInitialFinishesView); 604 } else { 605 pushInitialFinishesView(); 606 } 607 608 document.addEventListener("phos_consent_updated", pushFinishesViewAfterConsent); 609})(); 610 611 612 document.addEventListener("DOMContentLoaded", function() { 613 // Find all links with href="/products/all & change it to /products-view" 614 var links = document.querySelectorAll('a[href="/finishes/all"]'); 615 616 links.forEach(function(link) { 617 link.setAttribute("href", "/finishes-view"); 618 }); 619}); 620 621 622// project pages GTM event tracking with consent management 623 624(function () { 625 var hasPushedInitialProjectsView = false; 626 627 function isProjectsPage() { 628 var path = window.location.pathname.toLowerCase(); 629 630 return ( 631 path === "/projects" || 632 path === "/projects/" || 633 path === "/projects-view" || 634 path === "/projects-view/" || 635 path.indexOf("/projects/") === 0 636 ); 637 } 638 639 function getProjectsName() { 640 var h1 = document.querySelector("h1"); 641 642 if (h1 && h1.innerText) { 643 return h1.innerText.trim(); 644 } 645 646 var title = document.title || ""; 647 return title.replace("[PHOS] -", "").trim(); 648 } 649 650 function getConsentCookie() { 651 var name = "phos_consent_v2="; 652 var cookies = document.cookie ? document.cookie.split(";") : []; 653 654 for (var i = 0; i < cookies.length; i++) { 655 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 656 657 if (c.indexOf(name) === 0) { 658 try { 659 return JSON.parse(decodeURIComponent(c.substring(name.length))); 660 } catch (e) { 661 return null; 662 } 663 } 664 } 665 666 return null; 667 } 668 669 function hasAnalyticsConsent(consent) { 670 return consent && consent.analytics === true; 671 } 672 673 function pushProjectsView(source) { 674 if (!isProjectsPage()) { 675 console.log("GTM projects-view not pushed: not a projects page", window.location.pathname); 676 return; 677 } 678 679 window.dataLayer = window.dataLayer || []; 680 681 var eventData = { 682 event: "projects-view", 683 event_source: source || "page_load", 684 page_url: window.location.href, 685 page_path: window.location.pathname, 686 page_title: document.title, 687 projects_name: getProjectsName() 688 }; 689 690 window.dataLayer.push(eventData); 691 692 console.log("GTM projects-view pushed:", eventData); 693 } 694 695 function pushInitialProjectsView() { 696 if (hasPushedInitialProjectsView) return; 697 698 var consent = getConsentCookie(); 699 700 if (!hasAnalyticsConsent(consent)) { 701 console.log("GTM projects-view not pushed: analytics consent not granted"); 702 return; 703 } 704 705 hasPushedInitialProjectsView = true; 706 pushProjectsView("page_load"); 707 } 708 709 function pushProjectsViewAfterConsent(e) { 710 if (hasPushedInitialProjectsView) return; 711 712 var detail = e && e.detail ? e.detail : null; 713 var consent = detail || getConsentCookie(); 714 715 if (!hasAnalyticsConsent(consent)) return; 716 717 hasPushedInitialProjectsView = true; 718 pushProjectsView("consent_granted"); 719 } 720 721 if (document.readyState === "loading") { 722 document.addEventListener("DOMContentLoaded", pushInitialProjectsView); 723 } else { 724 pushInitialProjectsView(); 725 } 726 727 document.addEventListener("phos_consent_updated", pushProjectsViewAfterConsent); 728})(); 729 730 731 document.addEventListener("DOMContentLoaded", function() { 732 // Find all links with href="/projects/all & change it to /projects-view" 733 var links = document.querySelectorAll('a[href="/projects/all"]'); 734 735 links.forEach(function(link) { 736 link.setAttribute("href", "/projects-view"); 737 }); 738}); 739 740 741// tech hub pages GTM event tracking with consent management 742 743(function () { 744 var hasPushedInitialTechhubView = false; 745 746 function isTechhubPage() { 747 var path = window.location.pathname.toLowerCase(); 748 749 return ( 750 path === "/tech-hub" || 751 path === "/tech-hub/" || 752 path === "/tech-hub/view" || 753 path === "/tech-hub/view/" || 754 path.indexOf("/tech-hub/") === 0 755 ); 756 } 757
758 function getTechhubName() { 759 var h1 = document.querySelector("h1"); 760 761 if (h1 && h1.innerText) { 762 return h1.innerText.trim(); 763 } 764 765 var title = document.title || ""; 766 return title.replace("[PHOS] -", "").trim(); 767 } 768 769 function getConsentCookie() { 770 var name = "phos_consent_v2="; 771 var cookies = document.cookie ? document.cookie.split(";") : []; 772 773 for (var i = 0; i < cookies.length; i++) { 774 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 775 776 if (c.indexOf(name) === 0) { 777 try { 778 return JSON.parse(decodeURIComponent(c.substring(name.length))); 779 } catch (e) { 780 return null; 781 } 782 } 783 } 784 785 return null; 786 } 787 788 function hasAnalyticsConsent(consent) { 789 return consent && consent.analytics === true; 790 } 791 792 function pushTechhubView(source) { 793 if (!isTechhubPage()) { 794 console.log("GTM techhub-view not pushed: not a techhub page", window.location.pathname); 795 return; 796 } 797 798 window.dataLayer = window.dataLayer || []; 799 800 var eventData = { 801 event: "tech-hub-view", 802 event_source: source || "page_load", 803 page_url: window.location.href, 804 page_path: window.location.pathname, 805 page_title: document.title, 806 techhub_name: getTechhubName() 807 }; 808 809 window.dataLayer.push(eventData); 810 811 console.log("GTM techhub-view pushed:", eventData); 812 } 813 814 function pushInitialTechhubView() { 815 if (hasPushedInitialTechhubView) return; 816 817 var consent = getConsentCookie(); 818 819 if (!hasAnalyticsConsent(consent)) { 820 console.log("GTM techhub-view not pushed: analytics consent not granted"); 821 return; 822 } 823 824 hasPushedInitialTechhubView = true; 825 pushTechhubView("page_load"); 826 } 827 828 function pushTechhubViewAfterConsent(e) { 829 if (hasPushedInitialTechhubView) return; 830 831 var detail = e && e.detail ? e.detail : null; 832 var consent = detail || getConsentCookie(); 833 834 if (!hasAnalyticsConsent(consent)) return; 835 836 hasPushedInitialTechhubView = true; 837 pushTechhubView("consent_granted"); 838 } 839 840 if (document.readyState === "loading") { 841 document.addEventListener("DOMContentLoaded", pushInitialTechhubView); 842 } else { 843 pushInitialTechhubView(); 844 } 845 846 document.addEventListener("phos_consent_updated", pushTechhubViewAfterConsent); 847})(); 848 849 850 document.addEventListener("DOMContentLoaded", function() { 851 // Find all links with href="/tech-hub/all & change it to /tech-hub-view" 852 var links = document.querySelectorAll('a[href="/tech-hub/all"]'); 853 854 links.forEach(function(link) { 855 link.setAttribute("href", "/tech-hub-view"); 856 }); 857}); 858 859 860// tech hub pages GTM event tracking with consent management 861 862(function () { 863 var hasPushedInitialBlogsView = false; 864 865 function isBlogsPage() { 866 var path = window.location.pathname.toLowerCase(); 867 868 return ( 869 path === "/blogs" || 870 path === "/blogs/view" || 871 path === "/blogs/view/" || 872 path.indexOf("/blogs/") === 0 873 ); 874 } 875 876 function getBlogsName() { 877 var h1 = document.querySelector("h1"); 878 879 if (h1 && h1.innerText) { 880 return h1.innerText.trim(); 881 } 882 883 var title = document.title || ""; 884 return title.replace("[PHOS] -", "").trim(); 885 } 886 887 function getConsentCookie() { 888 var name = "phos_consent_v2="; 889 var cookies = document.cookie ? document.cookie.split(";") : []; 890 891 for (var i = 0; i < cookies.length; i++) { 892 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 893 894 if (c.indexOf(name) === 0) { 895 try { 896 return JSON.parse(decodeURIComponent(c.substring(name.length))); 897 } catch (e) { 898 return null; 899 } 900 } 901 } 902 903 return null; 904 } 905 906 function hasAnalyticsConsent(consent) { 907 return consent && consent.analytics === true; 908 } 909 910 function pushBlogsView(source) { 911 if (!isBlogsPage()) { 912 console.log("GTM blogs-view not pushed: not a blogs page", window.location.pathname); 913 return; 914 } 915 916 window.dataLayer = window.dataLayer || []; 917 918 var eventData = { 919 event: "blogs-view", 920 event_source: source || "page_load", 921 page_url: window.location.href, 922 page_path: window.location.pathname, 923 page_title: document.title, 924 blogs_name: getBlogsName() 925 }; 926 927 window.dataLayer.push(eventData); 928 929 console.log("GTM blogs-view pushed:", eventData); 930 } 931 932 function pushInitialBlogsView() { 933 if (hasPushedInitialBlogsView) return; 934 935 var consent = getConsentCookie(); 936 937 if (!hasAnalyticsConsent(consent)) { 938 console.log("GTM blogs-view not pushed: analytics consent not granted"); 939 return; 940 } 941 942 hasPushedInitialBlogsView = true; 943 pushBlogsView("page_load"); 944 } 945 946 function pushBlogsViewAfterConsent(e) { 947 if (hasPushedInitialBlogsView) return; 948 949 var detail = e && e.detail ? e.detail : null; 950 var consent = detail || getConsentCookie(); 951 952 if (!hasAnalyticsConsent(consent)) return; 953 954 hasPushedInitialBlogsView = true; 955 pushBlogsView("consent_granted"); 956 } 957 958 if (document.readyState === "loading") { 959 document.addEventListener("DOMContentLoaded", pushInitialBlogsView); 960 } else { 961 pushInitialBlogsView(); 962 } 963 964 document.addEventListener("phos_consent_updated", pushBlogsViewAfterConsent); 965})(); 966 967 968 document.addEventListener("DOMContentLoaded", function() { 969 // Find all links with href="/blogs/all & change it to /blogs-view" 970 var links = document.querySelectorAll('a[href="/blogs/all"]'); 971 972 links.forEach(function(link) { 973 link.setAttribute("href", "/blogs-view"); 974 }); 975}); 976 977// light-tribe pages GTM event tracking with consent management 978 979(function () { 980 var hasPushedInitialLightTribeView = false; 981 982 function isLightTribePage() { 983 var path = window.location.pathname.toLowerCase(); 984 985 return ( 986 path === "/light-tribe" || 987 path === "/light-tribe/view" || 988 path === "/light-tribe/view/" || 989 path.indexOf("/light-tribe/") === 0 990 ); 991 } 992 993 function getLightTribeName() { 994 var h1 = document.querySelector("h1"); 995 996 if (h1 && h1.innerText) { 997 return h1.innerText.trim(); 998 } 999 1000 var title = document.title || ""; 1001 return title.replace("[PHOS] -", "").trim(); 1002 } 1003 1004 function getConsentCookie() { 1005 var name = "phos_consent_v2="; 1006 var cookies = document.cookie ? document.cookie.split(";") : []; 1007 1008 for (var i = 0; i < cookies.length; i++) { 1009 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1010 1011 if (c.indexOf(name) === 0) { 1012 try { 1013 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1014 } catch (e) { 1015 return null; 1016 } 1017 } 1018 } 1019 1020 return null; 1021 } 1022 1023 function hasAnalyticsConsent(consent) { 1024 return consent && consent.analytics === true; 1025 } 1026 1027 function pushLightTribeView(source) { 1028 if (!isLightTribePage()) { 1029 console.log("GTM light-tribe-view not pushed: not a light-tribe page", window.location.pathname); 1030 return; 1031 } 1032 1033 window.dataLayer = window.dataLayer || []; 1034 1035 var eventData = { 1036 event: "light-tribe-view", 1037 event_source: source || "page_load", 1038 page_url: window.location.href, 1039 page_path: window.location.pathname, 1040 page_title: document.title, 1041 light_tribe_name: getLightTribeName() 1042 }; 1043 1044 window.dataLayer.push(eventData); 1045 1046 console.log("GTM light-tribe-view pushed:", eventData); 1047 } 1048 1049 function pushInitialLightTribeView() { 1050 if (hasPushedInitialLightTribeView) return; 1051 1052 var consent = getConsentCookie(); 1053 1054 if (!hasAnalyticsConsent(consent)) { 1055 console.log("GTM light-tribe-view not pushed: analytics consent not granted"); 1056 return; 1057 } 1058 1059 hasPushedInitialLightTribeView = true; 1060 pushLightTribeView("page_load"); 1061 } 1062 1063 function pushLightTribeViewAfterConsent(e) { 1064 if (hasPushedInitialLightTribeView) return; 1065 1066 var detail = e && e.detail ? e.detail : null; 1067 var consent = detail || getConsentCookie(); 1068 1069 if (!hasAnalyticsConsent(consent)) return; 1070 1071 hasPushedInitialLightTribeView = true; 1072 pushLightTribeView("consent_granted"); 1073 } 1074 1075 if (document.readyState === "loading") { 1076 document.addEventListener("DOMContentLoaded", pushInitialLightTribeView); 1077 } else { 1078 pushInitialLightTribeView(); 1079 } 1080 1081 document.addEventListener("phos_consent_updated", pushLightTribeViewAfterConsent); 1082})(); 1083 1084 1085 document.addEventListener("DOMContentLoaded", function() { 1086 // Find all links with href="/light-tribe/all" & change it to /light-tribe-view" 1087 var links = document.querySelectorAll('a[href="/light-tribe/all"]'); 1088 1089 links.forEach(function(link) { 1090 link.setAttribute("href", "/light-tribe-view"); 1091 }); 1092}); 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105// MAIN WEBSITE PAGES 1106 1107// NA Configurator GTM event tracking 1108(function () { 1109 var hasPushedConfiguratorNa = false; 1110 1111 function isConfiguratorNaPage() { 1112 var path = window.location.pathname.toLowerCase(); 1113 1114 return ( 1115 path === "/products/all/configurna" || 1116 path === "/products/all/configurna/" 1117 ); 1118 } 1119 1120 function getConsentCookie() { 1121 var name = "phos_consent_v2="; 1122 var cookies = document.cookie ? document.cookie.split(";") : []; 1123 1124 for (var i = 0; i < cookies.length; i++) { 1125 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1126 1127 if (c.indexOf(name) === 0) { 1128 try { 1129 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1130 } catch (e) { 1131 return null; 1132 } 1133 } 1134 } 1135 1136 return null; 1137 } 1138 1139 function hasAnalyticsConsent() { 1140 var consent = getConsentCookie(); 1141 return consent && consent.analytics === true; 1142 } 1143 1144 function pushConfiguratorNa(source) { 1145 if (hasPushedConfiguratorNa) return; 1146 1147 if (!isConfiguratorNaPage()) { 1148 console.log("configurator-na not pushed. Current path:", window.location.pathname); 1149 return; 1150 } 1151 1152 if (!hasAnalyticsConsent()) { 1153 console.log("configurator-na not pushed. Analytics consent not granted."); 1154 return; 1155 } 1156 1157 hasPushedConfiguratorNa = true; 1158 1159 window.dataLayer = window.dataLayer || []; 1160 1161 window.dataLayer.push({ 1162 event: "configurator-na", 1163 event_source: source || "page_load", 1164 page_url: window.location.href, 1165 page_path: window.location.pathname, 1166 page_title: document.title 1167 }); 1168 1169 console.log("GTM configurator-na pushed"); 1170 } 1171
1172 function init() { 1173 pushConfiguratorNa("page_load"); 1174 } 1175 1176 if (document.readyState === "loading") { 1177 document.addEventListener("DOMContentLoaded", init); 1178 } else { 1179 init(); 1180 } 1181 1182 document.addEventListener("phos_consent_updated", function () { 1183 pushConfiguratorNa("consent_granted"); 1184 }); 1185})(); 1186 1187// INT Configurator GTM event tracking 1188(function () { 1189 var hasPushedConfiguratorInt = false; 1190 1191 function isConfiguratorIntPage() { 1192 var path = window.location.pathname.toLowerCase(); 1193 1194 return ( 1195 path === "/products/all/configeyp" || 1196 path === "/products/all/configeyp/" 1197 ); 1198 } 1199 1200 function getConsentCookie() { 1201 var name = "phos_consent_v2="; 1202 var cookies = document.cookie ? document.cookie.split(";") : []; 1203 1204 for (var i = 0; i < cookies.length; i++) { 1205 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1206 1207 if (c.indexOf(name) === 0) { 1208 try { 1209 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1210 } catch (e) { 1211 return null; 1212 } 1213 } 1214 } 1215 1216 return null; 1217 } 1218 1219 function hasAnalyticsConsent() { 1220 var consent = getConsentCookie(); 1221 return consent && consent.analytics === true; 1222 } 1223 1224 function pushConfiguratorInt(source) { 1225 if (hasPushedConfiguratorInt) return; 1226 1227 if (!isConfiguratorIntPage()) { 1228 console.log("configurator-int not pushed. Current path:", window.location.pathname); 1229 return; 1230 } 1231 1232 if (!hasAnalyticsConsent()) { 1233 console.log("configurator-int not pushed. Analytics consent not granted."); 1234 return; 1235 } 1236 1237 hasPushedConfiguratorInt = true; 1238 1239 window.dataLayer = window.dataLayer || []; 1240 1241 window.dataLayer.push({ 1242 event: "configurator-int", 1243 event_source: source || "page_load", 1244 page_url: window.location.href, 1245 page_path: window.location.pathname, 1246 page_title: document.title 1247 }); 1248 1249 console.log("GTM configurator-int pushed"); 1250 } 1251 1252 function init() { 1253 pushConfiguratorInt("page_load"); 1254 } 1255 1256 if (document.readyState === "loading") { 1257 document.addEventListener("DOMContentLoaded", init); 1258 } else { 1259 init(); 1260 } 1261 1262 document.addEventListener("phos_consent_updated", function () { 1263 pushConfiguratorInt("consent_granted"); 1264 }); 1265})(); 1266 1267 1268 1269 1270 1271 1272 1273 1274// Orba GTM event tracking 1275(function () { 1276 var hasPushedOrba = false; 1277 1278 function isOrbaPage() { 1279 var path = window.location.pathname.toLowerCase(); 1280 1281 return ( 1282 path === "/products/orba" 1283 ); 1284 } 1285 1286 function getConsentCookie() { 1287 var name = "phos_consent_v2="; 1288 var cookies = document.cookie ? document.cookie.split(";") : []; 1289 1290 for (var i = 0; i < cookies.length; i++) { 1291 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1292 1293 if (c.indexOf(name) === 0) { 1294 try { 1295 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1296 } catch (e) { 1297 return null; 1298 } 1299 } 1300 } 1301 1302 return null; 1303 } 1304 1305 function hasAnalyticsConsent() { 1306 var consent = getConsentCookie(); 1307 return consent && consent.analytics === true; 1308 } 1309 1310 function pushOrba(source) { 1311 if (hasPushedOrba) return; 1312 1313 if (!isOrbaPage()) { 1314 console.log("orba not pushed. Current path:", window.location.pathname); 1315 return; 1316 } 1317 1318 if (!hasAnalyticsConsent()) { 1319 console.log("orba not pushed. Analytics consent not granted."); 1320 return; 1321 } 1322 1323 hasPushedOrba = true; 1324 1325 window.dataLayer = window.dataLayer || []; 1326 1327 window.dataLayer.push({ 1328 event: "orba-view", 1329 event_source: source || "page_load", 1330 page_url: window.location.href, 1331 page_path: window.location.pathname, 1332 page_title: document.title 1333 }); 1334 1335 console.log("GTM orba-view pushed"); 1336 } 1337
1338 function init() { 1339 pushOrba("page_load"); 1340 } 1341 1342 if (document.readyState === "loading") { 1343 document.addEventListener("DOMContentLoaded", init); 1344 } else { 1345 init(); 1346 } 1347 1348 document.addEventListener("phos_consent_updated", function () { 1349 pushOrba("consent_granted"); 1350 }); 1351})(); 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363// Eyeconic Square GTM event tracking 1364(function () { 1365 var hasPushed = false; 1366 1367 function isEyeconicSquarePage() { 1368 var path = window.location.pathname.toLowerCase(); 1369 1370 // Must be a product page, and name both words. Anchoring to /products/ 1371 // keeps a blog post or search result that happens to mention them from 1372 // firing a product-view event. 1373 return ( 1374 path.indexOf("/products/") === 0 && 1375 path.indexOf("eyeconic") !== -1 && 1376 path.indexOf("square") !== -1 1377 ); 1378 } 1379 function getConsentCookie() { 1380 var name = "phos_consent_v2="; 1381 var cookies = document.cookie ? document.cookie.split(";") : []; 1382 1383 for (var i = 0; i < cookies.length; i++) { 1384 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1385 1386 if (c.indexOf(name) === 0) { 1387 try { 1388 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1389 } catch (e) { 1390 return null; 1391 } 1392 } 1393 } 1394 1395 return null; 1396 } 1397 1398 function hasAnalyticsConsent() { 1399 var consent = getConsentCookie(); 1400 return consent && consent.analytics === true; 1401 } 1402 1403 function pushEyeconicSquare(source) { 1404 if (hasPushed) return; 1405 1406 if (!isEyeconicSquarePage()) { 1407 console.log("eyeconic square not pushed. Current path:", window.location.pathname); 1408 return; 1409 } 1410 1411 if (!hasAnalyticsConsent()) { 1412 console.log("eyeconic square not pushed. Analytics consent not granted."); 1413 return; 1414 } 1415 1416 hasPushed = true; 1417 1418 window.dataLayer = window.dataLayer || []; 1419 1420 window.dataLayer.push({ 1421 event: "eyeconic-square-view", 1422 event_source: source || "page_load", 1423 page_url: window.location.href, 1424 page_path: window.location.pathname, 1425 page_title: document.title 1426 }); 1427 1428 console.log("GTM eyeconic-square-view pushed"); 1429 } 1430 1431 function init() { 1432 pushEyeconicSquare("page_load"); 1433 } 1434 1435 if (document.readyState === "loading") { 1436 document.addEventListener("DOMContentLoaded", init); 1437 } else { 1438 init(); 1439 } 1440 1441 document.addEventListener("phos_consent_updated", function () { 1442 pushEyeconicSquare("consent_granted"); 1443 }); 1444})(); 1445 1446 1447 1448 1449// Eclipse Square GTM event tracking 1450(function () { 1451 var hasPushed = false; 1452 1453 function isEclipseSquarePage() { 1454 var path = window.location.pathname.toLowerCase(); 1455 1456 // Must be a product page, and name both words. Anchoring to /products/ 1457 // keeps a blog post or search result that happens to mention them from 1458 // firing a product-view event. 1459 return ( 1460 path.indexOf("/products/") === 0 && 1461 path.indexOf("eclipse") !== -1 && 1462 path.indexOf("square") !== -1 1463 ); 1464 } 1465 function getConsentCookie() { 1466 var name = "phos_consent_v2="; 1467 var cookies = document.cookie ? document.cookie.split(";") : []; 1468 1469 for (var i = 0; i < cookies.length; i++) { 1470 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1471 1472 if (c.indexOf(name) === 0) { 1473 try { 1474 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1475 } catch (e) { 1476 return null; 1477 } 1478 } 1479 } 1480 1481 return null; 1482 } 1483 1484 function hasAnalyticsConsent() { 1485 var consent = getConsentCookie(); 1486 return consent && consent.analytics === true; 1487 } 1488 1489 function pushEclipseSquare(source) { 1490 if (hasPushed) return; 1491 1492 if (!isEclipseSquarePage()) { 1493 console.log("eclipse square not pushed. Current path:", window.location.pathname); 1494 return; 1495 } 1496 1497 if (!hasAnalyticsConsent()) { 1498 console.log("eclipse square not pushed. Analytics consent not granted."); 1499 return; 1500 } 1501 1502 hasPushed = true; 1503 1504 window.dataLayer = window.dataLayer || []; 1505 1506 window.dataLayer.push({ 1507 event: "eclipse-square-view", 1508 event_source: source || "page_load", 1509 page_url: window.location.href, 1510 page_path: window.location.pathname, 1511 page_title: document.title 1512 }); 1513 1514 console.log("GTM eclipse-square-view pushed"); 1515 } 1516
1517 function init() { 1518 pushEclipseSquare("page_load"); 1519 } 1520 1521 if (document.readyState === "loading") { 1522 document.addEventListener("DOMContentLoaded", init); 1523 } else { 1524 init(); 1525 } 1526 1527 document.addEventListener("phos_consent_updated", function () { 1528 pushEclipseSquare("consent_granted"); 1529 }); 1530})(); 1531 1532 1533 1534 1535 1536 1537 1538 1539// STAND ALONE PAGES 1540 1541// Downloadarea GTM event tracking 1542(function () { 1543 var hasPushedDownloadarea = false; 1544 1545 function isDownloadareaPage() { 1546 var path = window.location.pathname; 1547 1548 return ( 1549 path === "/cpd_ndoorsentence/downloadarea" || 1550 path === "/cpd_indoorsentence/downloadarea/" || 1551 1552 path === "/CPD_IndoorSentence/downloadarea" || 1553 path === "/CPD_Indoorsentence/downloadarea/" || 1554 1555 path === "/standalone_pages/downloadarea/downloadarea.aspx" || 1556 path === "/standalone_pages/downloadarea/downloadarea" 1557 ); 1558 } 1559 1560 function getConsentCookie() { 1561 var name = "phos_consent_v2="; 1562 var cookies = document.cookie ? document.cookie.split(";") : []; 1563 1564 for (var i = 0; i < cookies.length; i++) { 1565 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1566 1567 if (c.indexOf(name) === 0) { 1568 try { 1569 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1570 } catch (e) { 1571 return null; 1572 } 1573 } 1574 } 1575 1576 return null; 1577 } 1578 1579 function hasAnalyticsConsent() { 1580 var consent = getConsentCookie(); 1581 return consent && consent.analytics === true; 1582 } 1583 1584 function pushDownloadarea(source) { 1585 if (hasPushedDownloadarea) return; 1586 1587 if (!isDownloadareaPage()) { 1588 console.log("downloadarea not pushed. Current path:", window.location.pathname); 1589 return; 1590 } 1591 1592 if (!hasAnalyticsConsent()) { 1593 console.log("downloadarea not pushed. Analytics consent not granted."); 1594 return; 1595 } 1596 1597 hasPushedDownloadarea = true; 1598 1599 window.dataLayer = window.dataLayer || []; 1600 1601 window.dataLayer.push({ 1602 event: "download-area", 1603 event_source: source || "page_load", 1604 page_url: window.location.href, 1605 page_path: window.location.pathname, 1606 page_title: document.title 1607 }); 1608 1609 console.log("GTM downloadarea pushed"); 1610 } 1611 1612 function init() { 1613 pushDownloadarea("page_load"); 1614 } 1615 1616 if (document.readyState === "loading") { 1617 document.addEventListener("DOMContentLoaded", init); 1618 } else { 1619 init(); 1620 } 1621 1622 document.addEventListener("phos_consent_updated", function () { 1623 pushDownloadarea("consent_granted"); 1624 }); 1625})(); 1626 1627// GenericThank You GTM event tracking 1628(function () { 1629 var hasPushedThankYou = false; 1630 1631 function isThankYouPage() { 1632 var path = window.location.pathname; 1633 1634 return ( 1635 path === "/Thank-you-phos" || 1636 path === "/Thank-you-phos/" 1637 1638 ); 1639 } 1640 1641 function getConsentCookie() { 1642 var name = "phos_consent_v2="; 1643 var cookies = document.cookie ? document.cookie.split(";") : []; 1644 1645 for (var i = 0; i < cookies.length; i++) { 1646 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1647 1648 if (c.indexOf(name) === 0) { 1649 try { 1650 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1651 } catch (e) { 1652 return null; 1653 } 1654 } 1655 } 1656 1657 return null; 1658 } 1659 1660 function hasAnalyticsConsent() { 1661 var consent = getConsentCookie(); 1662 return consent && consent.analytics === true; 1663 } 1664 1665 function pushThankYou(source) { 1666 if (hasPushedThankYou) return; 1667 1668 if (!isThankYouPage()) { 1669 console.log("thank you not pushed. Current path:", window.location.pathname); 1670 return; 1671 } 1672 1673 if (!hasAnalyticsConsent()) { 1674 console.log("thank you not pushed. Analytics consent not granted."); 1675 return; 1676 } 1677 1678 hasPushedThankYou = true; 1679 1680 window.dataLayer = window.dataLayer || []; 1681 1682 window.dataLayer.push({ 1683 event: "thank-you-gen", 1684 event_source: source || "page_load", 1685 page_url: window.location.href, 1686 page_path: window.location.pathname, 1687 page_title: document.title 1688 }); 1689 1690 console.log("GTM thank you page pushed"); 1691 } 1692
1693 function init() { 1694 pushThankYou("page_load"); 1695 } 1696 1697 if (document.readyState === "loading") { 1698 document.addEventListener("DOMContentLoaded", init); 1699 } else { 1700 init(); 1701 } 1702 1703 document.addEventListener("phos_consent_updated", function () { 1704 pushThankYou("consent_granted"); 1705 }); 1706})(); 1707 1708// product gen demo form GTM event tracking 1709(function () { 1710 var hasPushedDemoForm = false; 1711 1712 function isDemoFormPage() { 1713 var path = window.location.pathname; 1714 1715 return ( 1716 path === "/product_demo_form" || 1717 path === "/product_demo_form/" 1718 1719 ); 1720 } 1721 1722 function getConsentCookie() { 1723 var name = "phos_consent_v2="; 1724 var cookies = document.cookie ? document.cookie.split(";") : []; 1725 1726 for (var i = 0; i < cookies.length; i++) { 1727 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1728 1729 if (c.indexOf(name) === 0) { 1730 try { 1731 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1732 } catch (e) { 1733 return null; 1734 } 1735 } 1736 } 1737 1738 return null; 1739 } 1740 1741 function hasAnalyticsConsent() { 1742 var consent = getConsentCookie(); 1743 return consent && consent.analytics === true; 1744 } 1745 1746 function pushDemoForm(source) { 1747 if (hasPushedDemoForm) return; 1748 1749 if (!isDemoFormPage()) { 1750 console.log("demo form not pushed. Current path:", window.location.pathname); 1751 return; 1752 } 1753 1754 if (!hasAnalyticsConsent()) { 1755 console.log("demo form not pushed. Analytics consent not granted."); 1756 return; 1757 } 1758 1759 hasPushedDemoForm = true; 1760 1761 window.dataLayer = window.dataLayer || []; 1762 1763 window.dataLayer.push({ 1764 event: "product-demo-form", 1765 event_source: source || "page_load", 1766 page_url: window.location.href, 1767 page_path: window.location.pathname, 1768 page_title: document.title 1769 }); 1770 1771 console.log("GTM demo form page pushed"); 1772 } 1773 1774 function init() { 1775 pushDemoForm("page_load"); 1776 } 1777 1778 if (document.readyState === "loading") { 1779 document.addEventListener("DOMContentLoaded", init); 1780 } else { 1781 init(); 1782 } 1783 1784 document.addEventListener("phos_consent_updated", function () { 1785 pushDemoForm("consent_granted"); 1786 }); 1787})(); 1788 1789// product pro demo form GTM event tracking 1790(function () { 1791 var hasPushedEypDemoForm = false; 1792 1793 function isEypDemoFormPage() { 1794 var path = window.location.pathname; 1795 1796 return ( 1797 path === "/eyp-demo_form" || 1798 path === "/eyp-demo_form/" 1799 1800 ); 1801 } 1802 1803 function getConsentCookie() { 1804 var name = "phos_consent_v2="; 1805 var cookies = document.cookie ? document.cookie.split(";") : []; 1806 1807 for (var i = 0; i < cookies.length; i++) { 1808 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1809 1810 if (c.indexOf(name) === 0) { 1811 try { 1812 return JSON.parse(decodeURIComponent(c.substring(name.length))); 1813 } catch (e) { 1814 return null; 1815 } 1816 } 1817 } 1818 1819 return null; 1820 } 1821 1822 function hasAnalyticsConsent() { 1823 var consent = getConsentCookie(); 1824 return consent && consent.analytics === true; 1825 } 1826 1827 function pushEypDemoForm(source) { 1828 if (hasPushedEypDemoForm) return; 1829 1830 if (!isEypDemoFormPage()) { 1831 console.log("demo form not pushed. Current path:", window.location.pathname); 1832 return; 1833 } 1834 1835 if (!hasAnalyticsConsent()) { 1836 console.log("demo form not pushed. Analytics consent not granted."); 1837 return; 1838 } 1839 1840 hasPushedEypDemoForm = true; 1841 1842 window.dataLayer = window.dataLayer || []; 1843 1844 window.dataLayer.push({ 1845 event: "eyp-demo-form", 1846 event_source: source || "page_load", 1847 page_url: window.location.href, 1848 page_path: window.location.pathname, 1849 page_title: document.title 1850 }); 1851 1852 console.log("GTM eyp demo form page pushed"); 1853 } 1854
1855 function init() { 1856 pushEypDemoForm("page_load"); 1857 } 1858 1859 if (document.readyState === "loading") { 1860 document.addEventListener("DOMContentLoaded", init); 1861 } else { 1862 init(); 1863 } 1864 1865 document.addEventListener("phos_consent_updated", function () { 1866 pushDemoForm("consent_granted"); 1867 }); 1868})(); 1869 1870// CPD standalone page GTM event tracking 1871(function () { 1872 var hasPushedCpdStandalonePage = false; 1873 1874 function isCpdStandalonePage() { 1875 var path = window.location.pathname; 1876 1877 console.log("CPD current pathname:", path); 1878 1879 return ( 1880 path === "/LightTribe/CPD/TheIndoorSentence" || 1881 path === "/LightTribe/CPD/TheIndoorSentence/" 1882 ); 1883 } 1884 1885 function getConsentCookie() { 1886 var name = "phos_consent_v2="; 1887 var cookies = document.cookie ? document.cookie.split(";") : []; 1888 1889 for (var i = 0; i < cookies.length; i++) { 1890 var c = cookies[i].replace(/^\s+|\s+$/g, ""); 1891 1892 if (c.indexOf(name) === 0) { 1893 try { 1894 var consent = JSON.parse(decodeURIComponent(c.substring(name.length))); 1895 console.log("CPD consent cookie:", consent); 1896 return consent; 1897 } catch (e) { 1898 console.log("CPD consent cookie parse error:", e); 1899 return null; 1900 } 1901 } 1902 } 1903 1904 console.log("CPD consent cookie not found."); 1905 return null; 1906 } 1907 1908 function hasAnalyticsConsent() { 1909 var consent = getConsentCookie(); 1910 var allowed = consent && consent.analytics === true; 1911 1912 console.log("CPD analytics consent allowed:", allowed); 1913 1914 return allowed; 1915 } 1916 1917 function pushCpdStandalonePage(source) { 1918 console.log("CPD push attempt:", source); 1919 1920 if (hasPushedCpdStandalonePage) { 1921 console.log("CPD not pushed. Already pushed."); 1922 return; 1923 } 1924 1925 if (!isCpdStandalonePage()) { 1926 console.log("CPD not pushed. URL path does not match:", window.location.pathname); 1927 return; 1928 } 1929 1930 if (!hasAnalyticsConsent()) { 1931 console.log("CPD not pushed. Analytics consent not granted."); 1932 return; 1933 } 1934 1935 hasPushedCpdStandalonePage = true; 1936 1937 window.dataLayer = window.dataLayer || []; 1938 1939 window.dataLayer.push({ 1940 event: "cpd-standalone-page", 1941 event_source: source || "page_load", 1942 page_url: window.location.href, 1943 page_path: window.location.pathname, 1944 page_title: document.title 1945 }); 1946 1947 console.log("GTM CPD standalone page pushed:", { 1948 event: "cpd-standalone-page", 1949 page_path: window.location.pathname 1950 }); 1951 } 1952 1953 function init() { 1954 pushCpdStandalonePage("page_load"); 1955 } 1956 1957 if (document.readyState === "loading") { 1958 document.addEventListener("DOMContentLoaded", init); 1959 } else { 1960 init(); 1961 } 1962 1963 document.addEventListener("phos_consent_updated", function () { 1964 pushCpdStandalonePage("consent_granted"); 1965 }); 1966})(); 1967
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.