Insights – Stay Ahead with Expert Knowledge
Explore industry trends, best practices, and expert insights on webdevelopment, digital strategy, and business growth.

Spotlight on Insights

Blogs

/** * Summit Signal - AI-Powered Conversion Optimization * Version: 3.0.0 * * This script enables: * 1. Event tracking for user behavior * 2. A/B test implementation via CSS selectors (no manual attributes needed) * 3. Dynamic content optimization based on AI suggestions */ (function() { 'use strict'; // Configuration const CONFIG = { API_URL: window.SUMMIT_SIGNAL_API_URL || 'https://tfwfjryeygculbnkotzg.supabase.co/functions/v1', TRACKING_ID: window.SUMMIT_SIGNAL_ID || null, DEBUG: window.SUMMIT_SIGNAL_DEBUG || false }; if (!CONFIG.TRACKING_ID) { console.error('[Summit Signal] Missing SUMMIT_SIGNAL_ID'); return; } // Add anti-flicker CSS - hide elements until optimizations are applied const antiFlickerStyle = document.createElement('style'); antiFlickerStyle.id = 'summit-signal-anti-flicker'; antiFlickerStyle.textContent = ` [data-summit-loading] { opacity: 0 !important; transition: opacity 0.15s ease-in-out; } [data-summit-loaded] { opacity: 1 !important; } `; document.head.appendChild(antiFlickerStyle); // Timeout to prevent permanent hiding if API fails const ANTI_FLICKER_TIMEOUT = 2000; // Utility functions const log = (...args) => CONFIG.DEBUG && console.log('[Summit Signal]', ...args); const error = (...args) => console.error('[Summit Signal]', ...args); // Session management const getSessionId = () => { let sessionId = sessionStorage.getItem('summit_signal_session'); if (!sessionId) { sessionId = 'ss_' + Math.random().toString(36).substring(2, 15) + Date.now().toString(36); sessionStorage.setItem('summit_signal_session', sessionId); } return sessionId; }; const sessionId = getSessionId(); // Track applied tests to prevent duplicates const appliedTests = new Set(); // Event tracking const trackEvent = async (eventType, elementId, metadata = {}) => { try { const response = await fetch(`${CONFIG.API_URL}/summit-track-event`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ site_id: CONFIG.TRACKING_ID, event_type: eventType, element_id: elementId, session_id: sessionId, page_path: window.location.pathname, metadata }) }); if (!response.ok) { throw new Error(`HTTP ${response.status}`); } log(`Tracked ${eventType} on ${elementId}`); } catch (err) { error('Track event failed:', err); } }; /** * Find element using CSS selector or data-summit-id fallback */ const findElement = (cssSelector, elementId) => { // Try CSS selector first if (cssSelector) { const el = document.querySelector(cssSelector); if (el) { log(`Found element via CSS selector: ${cssSelector}`); return el; } log(`CSS selector not found: ${cssSelector}`); } // Fallback to data-summit-id for backwards compatibility if (elementId) { const el = document.querySelector(`[data-summit-id="${elementId}"]`); if (el) { log(`Found element via data-summit-id: ${elementId}`); return el; } } return null; }; // Visibility tracking (for elements with data-summit-id - backwards compatible) const setupVisibilityTracking = () => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting && entry.intersectionRatio >= 0.5) { const elementId = entry.target.getAttribute('data-summit-id'); if (elementId && !entry.target.dataset.summitTracked) { entry.target.dataset.summitTracked = 'true'; trackEvent('visible', elementId); } } }); }, { threshold: [0.5] }); document.querySelectorAll('[data-summit-id]').forEach(el => { observer.observe(el); }); // Watch for new elements const mutationObserver = new MutationObserver(() => { document.querySelectorAll('[data-summit-id]:not([data-summit-tracked])').forEach(el => { observer.observe(el); }); }); mutationObserver.observe(document.body, { childList: true, subtree: true }); }; // Click tracking const setupClickTracking = () => { document.addEventListener('click', (e) => { // Track clicks on tested elements const testedEl = e.target.closest('[data-summit-test]'); if (testedEl) { const testId = testedEl.dataset.summitTest; const variant = testedEl.dataset.summitVariant; trackEvent('cta-click', testId, { test_id: testId, variant }); log(`Click tracked: test=${testId}, variant=${variant}`); return; } // Backwards compatible: track clicks on data-summit-id elements const target = e.target.closest('[data-summit-id]'); if (target) { const elementId = target.getAttribute('data-summit-id'); trackEvent('cta-click', elementId); } }); }; // A/B Testing & Implementation const applyOptimizations = async (isInitial = false) => { // Track elements we're potentially modifying for anti-flicker const elementsToReveal = []; try { // Check for preview mode via URL params const urlParams = new URLSearchParams(window.location.search); const previewElement = urlParams.get('summit_preview') || urlParams.get('signal_preview') || urlParams.get('summit_preview_element'); const previewVariant = urlParams.get('summit_variant') || urlParams.get('variant') || urlParams.get('summit_preview_variant'); if (previewElement && previewVariant) { log(`Preview mode: showing ${previewVariant} for ${previewElement}`); // Show preview banner if (!document.getElementById('summit-signal-preview-banner')) { const banner = document.createElement('div'); banner.id = 'summit-signal-preview-banner'; banner.innerHTML = `
Explore industry trends, best practices, and expert insights on webdevelopment, digital strategy, and business growth.


