// Flag to prevent multiple script loads var nrichScriptLoaded = false; // Function to load the N.Rich script function loadNrichScript(cookielessMode) { if (nrichScriptLoaded) { console.log("N.Rich script already loaded."); return; } nrichScriptLoaded = true; console.log("Loading N.Rich script with cookieless mode:", cookielessMode); var config = { cookieless: cookielessMode, }; !function(n,a,t,i,f,y){ n[t]=n[t]||function(){(n[t].q=n[t].q||[]).push(arguments)}, n[t].l=1*new Date, f=a.createElement(i), f.async=true, y=a.getElementsByTagName(i)[0], f.src='https://serve.nrich.ai/tracker/assets/tracker.js?nto='+t, y.parentNode.insertBefore(f,y) }(window,document,'nt','script'); nt('load','1c53c9dc-268b-470e-8e18-b2dd2a63c5a3', config); } // Function to check consent and load the script accordingly function initializeNrich() { var consentGiven = cmplz_has_consent('marketing'); console.log("Consent given:", consentGiven); if (consentGiven) { console.log("Consent given, loading N.Rich with cookies."); loadNrichScript(false); // cookieless: false } else { console.log("Consent not given, loading N.Rich in cookieless mode."); loadNrichScript(true); // cookieless: true } } // Run initialization on page load document.addEventListener("DOMContentLoaded", function() { initializeNrich(); }); // Update N.Rich when consent status changes document.addEventListener("cmplzConsentStatus", function (e) { console.log("Consent status changed:", e.detail); // Reset the flag to allow reloading the script nrichScriptLoaded = false; initializeNrich(); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter