🔴 Live Users Tracker

Real-time website analytics dashboard

📋 Install Tracking Code

Copy and paste this tracking code into your website's HTML (before closing </body> tag) to start receiving live visitor data:

✅ Once installed, your website will start sending live visitor data to this dashboard automatically.

0
Current Visitors
LIVE
0
Unique Visitors (Last 30 Min)

📍 Location

Country -
State -
City -

💻 Device

Browser -
OS -
Device -

👥 Live Visitors

No active website selected

Please select a website to view live visitors

`; document.getElementById('trackingCode').value = trackingCodeHtml; document.getElementById('trackingCodeSection').style.display = 'block'; } function hideTrackingCode() { document.getElementById('trackingCodeSection').style.display = 'none'; } function copyTrackingCode() { const textarea = document.getElementById('trackingCode'); textarea.select(); textarea.setSelectionRange(0, 99999); // For mobile devices try { document.execCommand('copy'); const button = document.querySelector('.copy-button'); const originalText = button.textContent; button.textContent = 'Copied!'; button.style.background = '#22c55e'; setTimeout(() => { button.textContent = originalText; button.style.background = '#1e3c72'; }, 2000); } catch (err) { console.error('Failed to copy text: ', err); alert('Failed to copy code. Please select and copy manually.'); } } // Advanced Analytics Functions function getAnalyticsSummary() { if (!currentWebsite || !visitorsData[currentWebsite.url]) { return null; } const visitors = visitorsData[currentWebsite.url]; const now = new Date(); const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000); const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000); const hourlyVisitors = visitors.filter(v => v.timestamp > oneHourAgo); const dailyVisitors = visitors.filter(v => v.timestamp > oneDayAgo); return { currentActive: visitors.filter(v => v.isActive).length, lastHour: hourlyVisitors.length, lastDay: dailyVisitors.length, totalTracked: visitors.length, topCountries: getTopItems(visitors, 'country', 5), topBrowsers: getTopItems(visitors, 'browser', 5), topDevices: getTopItems(visitors, 'device', 3) }; } function getTopItems(visitors, field, limit = 5) { const counts = {}; visitors.forEach(visitor => { counts[visitor[field]] = (counts[visitor[field]] || 0) + 1; }); return Object.entries(counts) .sort(([,a], [,b]) => b - a) .slice(0, limit) .map(([item, count]) => ({ item, count })); } // Export data functionality function exportData() { if (!currentWebsite || !visitorsData[currentWebsite.url]) { alert('No website selected or no data available'); return; } const data = { website: currentWebsite, visitors: visitorsData[currentWebsite.url], exportTime: new Date().toISOString(), summary: getAnalyticsSummary() }; const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `${currentWebsite.name.replace(/[^a-z0-9]/gi, '_')}_analytics_${new Date().toISOString().split('T')[0]}.json`; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } // Keyboard shortcuts document.addEventListener('keydown', (e) => { if (e.ctrlKey || e.metaKey) { switch(e.key) { case 'r': e.preventDefault(); if (currentWebsite) { updateDashboard(); } break; case 'e': e.preventDefault(); exportData(); break; } } }); // Initialize everything when DOM is loaded if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initializeApp); } else { initializeApp(); }