(function() { "use strict"; var apiEndpoint = 'https://node.streamingworld.xyz/tracker.php'; // Replace with your API var siteId = window.location.hostname; // Get or generate a unique session ID using localStorage function getSessionId() { if (!localStorage.getItem('sessionId')) { localStorage.setItem('sessionId', Date.now() + '-' + Math.random().toString(36).substr(2, 9)); } return localStorage.getItem('sessionId'); } // Track page view and send data to the backend function trackPageView() { var payload = { siteId: siteId, // Site identifier sessionId: getSessionId(), // Unique session ID per user page: window.location.href, // Current page URL referrer: document.referrer, // Referrer URL (if any) userAgent: navigator.userAgent, // User's browser information timestamp: Date.now() // Event timestamp }; // Send data to the backend fetch(apiEndpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }).then(response => response.json()) //.then(data => console.log('Tracking response:', data)) .catch(error => console.error('Error tracking:', error)); } // Track page view when the script runs trackPageView(); })();