(function () {
    // Collect tracking data
    const data = {
        screen_width: window.innerWidth,
        screen_height: window.innerHeight,
        page_url: window.location.pathname + window.location.search,
        referrer: document.referrer,
    };

    // Send to WP backend
    fetch(pagevicoTracker.ajax_url, {
        method: 'POST',
        headers: { 
            'Content-Type': 'application/json',
            'X-WP-Nonce': pagevicoTracker.nonce
        },
        body: JSON.stringify(data),
    })
    .then(response => response.json())
    .then(result => {
        console.log('PageVICO Tracking Response:', result);
    })
    .catch(error => {
        console.error('PageVICO Tracking Error:', error);
    });
})();
  