<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://naturaprimeshop.shop/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://naturaprimeshop.shop/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://naturaprimeshop.shop/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://naturaprimeshop.shop/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://naturaprimeshop.shop/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
        <script>
        // Perfect Presell Advanced Tracking System
        window.ppAdvancedTrackingAjax = {
            ajax_url: "https://naturaprimeshop.shop/wp-admin/admin-ajax.php",
            presell_id: 1        };
        window.ppPresellId = 1;
        
        // JavaScript inline simples para tracking
        (function() {
            let startTime = Date.now();
            let sessionId = 'integrated_' + Date.now();
            
            console.log("PP Advanced Tracking: Configurado com Presell ID:", window.ppPresellId);
            
            // Função para fazer tracking via AJAX
            function trackEvent(action, data) {
                const formData = new FormData();
                formData.append('action', action);
                formData.append('presell_id', window.ppPresellId);
                formData.append('session_id', sessionId);
                
                for (let key in data) {
                    formData.append(key, data[key]);
                }
                
                fetch(window.ppAdvancedTrackingAjax.ajax_url, {
                    method: 'POST',
                    body: formData
                })
                .then(response => response.json())
                .then(result => {
                    // Tracking silencioso - apenas log de erros se necessário
                    if (!result.success) {
                        console.warn("PP Tracking:", action, "failed");
                    }
                })
                .catch(error => {
                    console.warn("PP Tracking error:", action);
                });
            }
            
            // Criar sessão
            trackEvent('pp_create_session', {});
            
            // TIMER AUTOMÁTICO: Enviar tempo a cada 10 segundos (apenas quando página está ativa)
            let timerInterval = null;
            let pageActive = true;
            
            function startTimer() {
                if (timerInterval) return; // Já está rodando
                
                timerInterval = setInterval(function() {
                    if (!pageActive) {
                        console.log("⏸️ PP Tracking: Página inativa, pausando timer");
                        return;
                    }
                    
                    let timeOnPage = Math.round((Date.now() - startTime) / 1000);
                    let scrollPercentage = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100) || 0;
                    
                    // Enviar dados de tempo e scroll atual
                    trackEvent('pp_track_scroll', {
                        scroll_percentage: scrollPercentage,
                        time_on_page: timeOnPage
                    });
                    
                    console.log("⏱️ PP Tracking: Timer automático - " + timeOnPage + "s, scroll: " + scrollPercentage + "%");
                }, 10000); // A cada 10 segundos
            }
            
            function stopTimer() {
                if (timerInterval) {
                    clearInterval(timerInterval);
                    timerInterval = null;
                    console.log("⏹️ PP Tracking: Timer parado!");
                }
            }
            
            // Iniciar timer
            startTimer();
            
            // DETECTAR SAÍDA DA PÁGINA: Parar timer quando sair
            document.addEventListener('visibilitychange', function() {
                if (document.hidden) {
                    pageActive = false;
                    console.log("👁️ PP Tracking: Página oculta - pausando tracking");
                } else {
                    pageActive = true;
                    console.log("👁️ PP Tracking: Página visível - retomando tracking");
                }
            });
            
            // Parar timer definitivamente ao sair
            window.addEventListener('beforeunload', function() {
                pageActive = false;
                stopTimer();
                console.log("🚪 PP Tracking: Saindo da página - timer parado definitivamente");
            });
            
            // Parar timer quando perder foco
            window.addEventListener('blur', function() {
                pageActive = false;
                console.log("🔍 PP Tracking: Página perdeu foco - pausando");
            });
            
            // Retomar timer quando ganhar foco
            window.addEventListener('focus', function() {
                pageActive = true;
                console.log("🔍 PP Tracking: Página ganhou foco - retomando");
            });
            
            // EXIT INTENT TRACKING: Detectar quando mouse vai para cima (tentativa de sair)
            let exitIntentTriggered = false;
            
            document.addEventListener('mouseleave', function(e) {
                // Se mouse saiu pela parte superior da página
                if (e.clientY <= 0 && !exitIntentTriggered) {
                    exitIntentTriggered = true;
                    console.log("🚪 PP Tracking: EXIT INTENT detectado! Mouse saiu pela parte superior");
                    
                    // Marcar como exit intent (potencial fuga)
                    let timeOnPage = Math.round((Date.now() - startTime) / 1000);
                    trackEvent('pp_track_exit', {
                        exit_type: 'mouse_leave',
                        time_on_page: timeOnPage
                    });
                }
            });
            
            // Detectar tentativa de fechar aba/navegador
            window.addEventListener('beforeunload', function(e) {
                // VERIFICAR SE É REDIRECIONAMENTO LEGÍTIMO
                const isLegitimateRedirect = sessionStorage.getItem('pp_legitimate_redirect') === 'true';
                const redirectTime = parseInt(sessionStorage.getItem('pp_redirect_time') || '0');
                const timeSinceClick = Date.now() - redirectTime;
                
                // Se clicou em link nos últimos 2 segundos, é redirecionamento legítimo
                if (isLegitimateRedirect && timeSinceClick < 2000) {
                    console.log("✅ PP Tracking: Redirecionamento legítimo detectado - NÃO é fuga!");
                    sessionStorage.removeItem('pp_legitimate_redirect');
                    sessionStorage.removeItem('pp_redirect_time');
                    return; // NÃO marcar como exit intent
                }
                
                if (!exitIntentTriggered) {
                    exitIntentTriggered = true;
                    console.log("🚪 PP Tracking: EXIT INTENT detectado! Tentativa de sair/fechar");
                    
                    let timeOnPage = Math.round((Date.now() - startTime) / 1000);
                    
                    // Usar sendBeacon para garantir envio
                    const formData = new FormData();
                    formData.append('action', 'pp_track_exit');
                    formData.append('presell_id', window.ppPresellId);
                    formData.append('session_id', sessionId);
                    formData.append('exit_type', 'beforeunload');
                    formData.append('time_on_page', timeOnPage);
                    
                    navigator.sendBeacon(window.ppAdvancedTrackingAjax.ajax_url, formData);
                }
            });
            
            // Track cliques
            document.addEventListener('click', function(e) {
                let timeOnPage = Math.round((Date.now() - startTime) / 1000);
                let clickType = 'presell'; // Padrão
                
                // DETECTAR CLIQUES EM LINKS DE AFILIADO
                let target = e.target;
                let link = target.closest('a');
                
                if (link && link.href) {
                    // Verificar se é link externo (afiliado)
                    let currentDomain = window.location.hostname;
                    let linkDomain = new URL(link.href).hostname;
                    
                    if (linkDomain !== currentDomain) {
                        clickType = 'affiliate';
                    }
                    
                    // Verificar padrões comuns de afiliado
                    if (link.href.includes('hotmart.com') || 
                        link.href.includes('monetizze.com') || 
                        link.href.includes('eduzz.com') ||
                        link.href.includes('kiwify.com') ||
                        link.href.includes('braip.com') ||
                        link.href.includes('perfectpay.com.br') ||
                        link.href.includes('pay.kiwify.com') ||
                        link.href.includes('checkout.') ||
                        link.href.includes('comprar') ||
                        link.href.includes('buy') ||
                        link.href.includes('offer')) {
                        clickType = 'affiliate';
                    }
                }
                
                // IMPORTANTE: Se clicou em qualquer link, NÃO é fuga (é sucesso/redirecionamento)
                if (link) {
                    exitIntentTriggered = false; // Reset exit intent
                    console.log("✅ PP Tracking: Clique em link detectado - NÃO é fuga!");
                    
                    // MARCAR COMO REDIRECIONAMENTO LEGÍTIMO
                    sessionStorage.setItem('pp_legitimate_redirect', 'true');
                    sessionStorage.setItem('pp_redirect_time', Date.now());
                }
                
                trackEvent('pp_track_click', {
                    click_type: clickType,
                    time_on_page: timeOnPage
                });
            });
            
            // Track scroll
            let lastScroll = 0;
            window.addEventListener('scroll', function() {
                let scrollPercentage = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100);
                if (scrollPercentage > lastScroll + 10) {
                    lastScroll = scrollPercentage;
                    let timeOnPage = Math.round((Date.now() - startTime) / 1000);
                    trackEvent('pp_track_scroll', {
                        scroll_percentage: scrollPercentage,
                        time_on_page: timeOnPage
                    });
                }
            });
            
            // TRACKING DE SAÍDA: Capturar tempo final quando sair da página
            window.addEventListener('beforeunload', function() {
                let finalTime = Math.round((Date.now() - startTime) / 1000);
                let finalScroll = Math.round((window.scrollY / (document.body.scrollHeight - window.innerHeight)) * 100) || 0;
                
                // Usar navigator.sendBeacon para garantir envio mesmo na saída
                const formData = new FormData();
                formData.append('action', 'pp_track_scroll');
                formData.append('presell_id', window.ppPresellId);
                formData.append('session_id', sessionId);
                formData.append('scroll_percentage', finalScroll);
                formData.append('time_on_page', finalTime);
                
                navigator.sendBeacon(window.ppAdvancedTrackingAjax.ajax_url, formData);
                console.log("🚪 PP Tracking: Saída da página - " + finalTime + "s, scroll: " + finalScroll + "%");
            });
            
            // Sistema inicializado com sucesso
        })();
        </script>
        