feat: captura o email assim que digitado, antes do checkout
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 <noreply@anthropic.com>
This commit is contained in:
parent
da4f3195b7
commit
f2e74cfc24
3 changed files with 19 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
14
src/utils/trackLead.ts
Normal file
14
src/utils/trackLead.ts
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue