// CRO Enhancements - Sticky Bar, Exit Intent, Tracking (function() { // Only run on blog articles if (!window.location.pathname.includes("/blog/articles/")) return; // Check if user already converted or dismissed var hasConverted = localStorage.getItem("ukds_converted"); var hasDismissed = localStorage.getItem("ukds_dismissed"); var dismissedAt = localStorage.getItem("ukds_dismissed_at"); // Reset dismissal after 7 days if (dismissedAt && Date.now() - parseInt(dismissedAt) > 7 * 24 * 60 * 60 * 1000) { localStorage.removeItem("ukds_dismissed"); localStorage.removeItem("ukds_dismissed_at"); hasDismissed = null; } // === STICKY CTA BAR === var stickyBar = document.createElement("div"); stickyBar.className = "sticky-cta-bar"; stickyBar.innerHTML = '
Need expert help with your data project?
' + 'Get Free Consultation' + ''; document.body.appendChild(stickyBar); // Show sticky bar after scrolling 40% var stickyShown = false; window.addEventListener("scroll", function() { var scrollPercent = (window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100; if (scrollPercent > 40 && !stickyShown && !hasDismissed) { stickyBar.classList.add("visible"); stickyShown = true; } }); window.closeStickyBar = function() { stickyBar.classList.remove("visible"); localStorage.setItem("ukds_dismissed", "sticky"); localStorage.setItem("ukds_dismissed_at", Date.now().toString()); }; // === EXIT INTENT POPUP === if (!hasConverted && !hasDismissed) { var popup = document.createElement("div"); popup.className = "exit-popup-overlay"; popup.innerHTML = '' + 'The same checklist we use for enterprise projects
' + 'We sent the checklist to ' + email + '
' + '' + 'Or talk to us now →' + '
'; // Send to endpoint fetch("/api/lead-capture.php", { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify({ email: email, source: "exit_popup", page: window.location.pathname }) }).catch(function(err) { console.error(err); }); }; } // === CTA TRACKING === window.trackCTA = function(action, label) { if (typeof gtag !== "undefined") { gtag("event", action, { event_category: "CRO", event_label: label || window.location.pathname }); } console.log("CTA tracked:", action, label); }; // Track all quote links document.querySelectorAll('a[href*="/quote"]').forEach(function(link) { link.addEventListener("click", function() { var isInlineCta = this.closest(".inline-cta") ? "inline_cta" : "other"; trackCTA("quote_click", isInlineCta); }); }); })(); // Social Proof Notification (function() { if (localStorage.getItem("ukds_social_proof_dismissed")) return; var messages = [ "3 businesses requested quotes today", "A London fintech just enquired about data scraping", "New project started: competitor price monitoring", "5 quotes sent this week" ]; var notification = document.createElement("div"); notification.id = "social-proof"; notification.style.cssText = "position:fixed;bottom:80px;left:20px;background:#fff;padding:15px 20px;border-radius:8px;box-shadow:0 4px 20px rgba(0,0,0,0.15);z-index:9998;display:none;max-width:280px;font-size:14px;border-left:4px solid #00cc66;"; notification.innerHTML = '