/** * 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 = `
🧪 Summit Signal Preview Mode - Viewing Variant ${previewVariant.toUpperCase()} for "${previewElement}"
`; document.body.prepend(banner); } } const response = await fetch(`${CONFIG.API_URL}/summit-signal-implement`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ site_tracking_id: CONFIG.TRACKING_ID, preview_element: previewElement, preview_variant: previewVariant }) }); if (!response.ok) { throw new Error(`HTTP ${response.status}`); } const data = await response.json(); log('Received optimizations:', data); // Apply winning variants (permanent changes) data.winners?.forEach(winner => { const element = findElement(winner.css_selector, winner.element_id); if (element) { element.textContent = winner.content; element.dataset.summitTest = winner.element_id; element.dataset.summitVariant = 'winner'; element.removeAttribute('data-summit-loading'); element.setAttribute('data-summit-loaded', 'true'); elementsToReveal.push(element); log(`Applied winner for ${winner.element_id}: "${winner.content}"`); } else { log(`Winner element not found: ${winner.element_id} (selector: ${winner.css_selector})`); } }); // Apply A/B test variants data.active_tests?.forEach(test => { // Skip if already applied if (appliedTests.has(test.element_id)) { log(`Test ${test.element_id} already applied, skipping`); return; } const element = findElement(test.css_selector, test.element_id); if (element) { // Check if this element is in preview mode const forceVariant = previewElement === test.element_id ? previewVariant : null; const showB = forceVariant ? (forceVariant === 'b' || forceVariant === 'variant_b') : test.show_variant_b; const variant = showB ? test.variant_b : test.variant_a; const variantLabel = showB ? 'b' : 'a'; // Store original content if (!element.dataset.summitOriginal) { element.dataset.summitOriginal = element.textContent; } element.textContent = variant; element.dataset.summitTest = test.test_id || test.element_id; element.dataset.summitVariant = variantLabel; element.removeAttribute('data-summit-loading'); element.setAttribute('data-summit-loaded', 'true'); elementsToReveal.push(element); appliedTests.add(test.element_id); if (forceVariant) { element.style.outline = '3px solid #f97316'; element.style.outlineOffset = '2px'; log(`Preview: forced variant ${forceVariant} for ${test.element_id}`); } else { log(`Applied variant ${variantLabel} for ${test.element_id}: "${variant}"`); } // Track impression (skip in preview mode) if (!previewElement) { trackEvent('ab-impression', test.element_id, { test_id: test.test_id, variant: variantLabel }); } } else { log(`Test element not found: ${test.element_id} (selector: ${test.css_selector})`); } }); log('Optimizations applied successfully'); } catch (err) { error('Apply optimizations failed:', err); // On error, reveal any hidden elements document.querySelectorAll('[data-summit-loading]').forEach(el => { el.removeAttribute('data-summit-loading'); el.setAttribute('data-summit-loaded', 'true'); }); } }; // Connection heartbeat const sendHeartbeat = async () => { try { const response = await fetch(`${CONFIG.API_URL}/verify-addon-connection`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ site_tracking_id: CONFIG.TRACKING_ID, ping_type: 'heartbeat', metadata: { page: window.location.pathname, timestamp: new Date().toISOString(), version: '3.0.0' } }) }); if (response.ok) { log('Heartbeat sent successfully'); } } catch (err) { error('Heartbeat failed:', err); } }; // Initialize const init = async () => { log('Initializing Signal v3.2.0 (anti-flicker mode)'); log('Tracking ID:', CONFIG.TRACKING_ID); // Set up anti-flicker timeout - ensure elements show even if API fails const antiFlickerTimeout = setTimeout(() => { document.querySelectorAll('[data-summit-loading]').forEach(el => { el.removeAttribute('data-summit-loading'); el.setAttribute('data-summit-loaded', 'true'); }); log('Anti-flicker timeout reached, revealing elements'); }, ANTI_FLICKER_TIMEOUT); // Send initial heartbeat (don't await - run in parallel) sendHeartbeat(); // Send heartbeat every 2 minutes setInterval(sendHeartbeat, 2 * 60 * 1000); // Apply optimizations first (before content is visible) await applyOptimizations(true); // Clear timeout since we've applied optimizations clearTimeout(antiFlickerTimeout); // Poll for new tests every 30 seconds (reduced frequency) setInterval(async () => { // Clear applied tests to allow re-fetching appliedTests.clear(); await applyOptimizations(false); }, 30 * 1000); // Set up tracking if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { setupVisibilityTracking(); setupClickTracking(); }); } else { setupVisibilityTracking(); setupClickTracking(); } log('Initialized successfully'); }; // Expose API for manual use window.SummitSignal = { trackEvent, applyOptimizations, version: '3.2.0' }; init(); })(); /** * Summit Wellness AI - 24/7 SEO Monitoring & Backlink Building * Version: 1.0.0 * * This script enables: * 1. Connection heartbeat monitoring * 2. SEO performance tracking * 3. Backlink monitoring * 4. Content health checks * 5. Technical SEO auditing */ (function() { 'use strict'; // Configuration const CONFIG = { API_URL: window.SUMMIT_WELLNESS_API_URL || 'https://tfwfjryeygculbnkotzg.supabase.co/functions/v1', TRACKING_ID: window.SUMMIT_WELLNESS_ID || null, DEBUG: window.SUMMIT_WELLNESS_DEBUG || false }; if (!CONFIG.TRACKING_ID) { console.error('[Summit Wellness] Missing SUMMIT_WELLNESS_ID'); return; } // Utility functions const log = (...args) => CONFIG.DEBUG && console.log('[Summit Wellness]', ...args); const error = (...args) => console.error('[Summit Wellness]', ...args); // Connection heartbeat const sendHeartbeat = async () => { try { const response = await fetch(`${CONFIG.API_URL}/verify-addon-connection`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ site_tracking_id: CONFIG.TRACKING_ID, ping_type: 'heartbeat', metadata: { page: window.location.pathname, timestamp: new Date().toISOString(), service: 'wellness' } }) }); if (response.ok) { log('Heartbeat sent successfully'); } } catch (err) { error('Heartbeat failed:', err); } }; // Collect SEO metadata for monitoring const collectSEOData = () => { const data = { title: document.title, description: document.querySelector('meta[name="description"]')?.content || '', keywords: document.querySelector('meta[name="keywords"]')?.content || '', canonical: document.querySelector('link[rel="canonical"]')?.href || window.location.href, og_title: document.querySelector('meta[property="og:title"]')?.content || '', og_description: document.querySelector('meta[property="og:description"]')?.content || '', og_image: document.querySelector('meta[property="og:image"]')?.content || '', h1_count: document.querySelectorAll('h1').length, h2_count: document.querySelectorAll('h2').length, img_without_alt: document.querySelectorAll('img:not([alt])').length, links_internal: document.querySelectorAll('a[href^="/"], a[href^="' + window.location.origin + '"]').length, links_external: document.querySelectorAll('a[href^="http"]:not([href^="' + window.location.origin + '"])').length, word_count: document.body.innerText.split(/\s+/).length, has_schema: !!document.querySelector('script[type="application/ld+json"]'), viewport: document.querySelector('meta[name="viewport"]')?.content || '', page_load_time: performance.timing.loadEventEnd - performance.timing.navigationStart }; log('SEO data collected:', data); return data; }; // Send wellness audit data const sendWellnessAudit = async () => { try { const seoData = collectSEOData(); const response = await fetch(`${CONFIG.API_URL}/summit-wellness-audit`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ site_id: CONFIG.TRACKING_ID, page_path: window.location.pathname, seo_data: seoData, timestamp: new Date().toISOString() }) }); if (response.ok) { log('Wellness audit sent successfully'); } } catch (err) { error('Wellness audit failed:', err); } }; // Check for broken images const checkBrokenImages = () => { const images = document.querySelectorAll('img'); const broken = []; images.forEach(img => { if (!img.complete || img.naturalHeight === 0) { broken.push({ src: img.src, alt: img.alt || 'No alt text' }); } }); if (broken.length > 0) { log('Broken images detected:', broken); } return broken; }; // Monitor page performance const trackPerformance = () => { if (window.performance && window.performance.timing) { const timing = window.performance.timing; const metrics = { dns_time: timing.domainLookupEnd - timing.domainLookupStart, tcp_time: timing.connectEnd - timing.connectStart, request_time: timing.responseEnd - timing.requestStart, dom_processing: timing.domComplete - timing.domLoading, total_load_time: timing.loadEventEnd - timing.navigationStart }; log('Performance metrics:', metrics); return metrics; } return null; }; // Initialize const init = async () => { log('Initializing Wellness v1.0.0'); log('Tracking ID:', CONFIG.TRACKING_ID); // Send initial heartbeat await sendHeartbeat(); // Send heartbeat every 2 minutes setInterval(sendHeartbeat, 2 * 60 * 1000); // Wait for page to fully load before collecting data if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', async () => { // Collect and send initial wellness audit setTimeout(async () => { await sendWellnessAudit(); checkBrokenImages(); trackPerformance(); }, 1000); // Wait 1 second after DOM ready }); } else { // Page already loaded setTimeout(async () => { await sendWellnessAudit(); checkBrokenImages(); trackPerformance(); }, 1000); } // Send wellness audit every 30 minutes setInterval(sendWellnessAudit, 30 * 60 * 1000); log('Initialized successfully'); }; init(); })();

Insights – Stay Ahead with Expert Knowledge

Explore industry trends, best practices, and expert insights on webdevelopment, digital strategy, and business growth.

Insights that Inspire

Blogs

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Let’s Build Something Great Together