From 243acb4aab1f862d055af5cd64c65995f437eb6e Mon Sep 17 00:00:00 2001 From: Marcio Bevervanso Date: Thu, 9 Jul 2026 16:53:04 -0300 Subject: [PATCH] feat: captura o email assim que digitado, antes do checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dispara trackLead pro /api/checkout/track-lead do app principal no momento que o usuário informa o email (landing + funil), não só quando chega a tentar pagar. Fire-and-forget, não trava a navegação. Co-Authored-By: Claude Sonnet 5 --- src/components/Offer.tsx | 2 ++ src/pages/WhatsAppFunnel.tsx | 3 +++ src/utils/trackLead.ts | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 src/utils/trackLead.ts diff --git a/src/components/Offer.tsx b/src/components/Offer.tsx index d21557b..6e6e751 100644 --- a/src/components/Offer.tsx +++ b/src/components/Offer.tsx @@ -2,6 +2,7 @@ import { useState, type FormEvent } from 'react'; import { motion } from 'framer-motion'; import { Check, ShieldCheck, Gift, ArrowRight, ImageIcon, Download, Clock, Headphones, Zap, Loader2 } from 'lucide-react'; import { cn } from '../lib/utils'; +import { trackLead } from '../utils/trackLead'; export default function Offer() { const benefits = [ @@ -30,6 +31,7 @@ export default function Offer() { setIsLoading(true); setError(''); + trackLead(email, 'landing-30', 'Kit Festa'); window.location.href = `https://festamagicaia.com.br/checkout?plan=popular&source=landing-30&email=${encodeURIComponent(email)}`; }; diff --git a/src/pages/WhatsAppFunnel.tsx b/src/pages/WhatsAppFunnel.tsx index 83023d4..cbdf269 100644 --- a/src/pages/WhatsAppFunnel.tsx +++ b/src/pages/WhatsAppFunnel.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, useRef, type FormEvent } from 'react'; import { Loader2, Send } from 'lucide-react'; +import { trackLead } from '../utils/trackLead'; type MessageType = 'text' | 'audio' | 'image' | 'video' | 'embed'; @@ -258,6 +259,8 @@ export default function WhatsAppFunnel() { (window as any).fbq('track', 'InitiateCheckout'); } + trackLead(emailInput, 'funil-30', 'Kit Festa'); + setTimeout(() => { window.location.href = `https://festamagicaia.com.br/checkout?plan=popular&source=funil-30&email=${encodeURIComponent(emailInput)}`; }, 800); diff --git a/src/utils/trackLead.ts b/src/utils/trackLead.ts new file mode 100644 index 0000000..115f636 --- /dev/null +++ b/src/utils/trackLead.ts @@ -0,0 +1,14 @@ +// Dispara best-effort, sem travar a navegação — se falhar, ninguém percebe. +// keepalive garante que a requisição sobrevive ao redirect que vem logo em seguida. +export function trackLead(email: string, source: string, planName?: string) { + try { + fetch('https://www.festamagicaia.com.br/api/checkout/track-lead', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email, source, planName }), + keepalive: true, + }).catch(() => {}); + } catch { + // no-op + } +}