diff --git a/src/components/Offer.tsx b/src/components/Offer.tsx index 8d8a2ad..12b59d7 100644 --- a/src/components/Offer.tsx +++ b/src/components/Offer.tsx @@ -2,6 +2,7 @@ import { useState, type FormEvent } from 'react'; import { Check, ShieldCheck, Gift, ArrowRight, Loader2 } from 'lucide-react'; import { cn } from '../lib/utils'; import { useT, getLang } from '../i18n'; +import { trackLead } from '../utils/trackLead'; export default function Offer() { const t = useT(); @@ -29,6 +30,7 @@ export default function Offer() { setError(''); const isBR = getLang() === 'pt'; + trackLead(email, isBR ? 'landing' : 'landing-international', 'Starter'); if (!isBR) { // Internacional: Starter USD $6.99 → Stripe direto diff --git a/src/pages/WhatsAppFunnel.tsx b/src/pages/WhatsAppFunnel.tsx index 6bd5cdc..99805f8 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'; @@ -274,6 +275,8 @@ export default function WhatsAppFunnel() { (window as any).fbq('track', 'InitiateCheckout'); } + trackLead(emailInput, 'funil', 'Starter'); + setTimeout(() => { window.location.href = `https://festamagicaia.com.br/checkout?plan=starter&source=funil&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 + } +}