Track Umami goal 'umow-rozmowe' on successful contact submit

Fire window.umami?.track('umow-rozmowe') right after the mailer returns
200 (status -> 'success'), so the conversion goal counts only real sends,
not validation errors, network failures, or button clicks. Optional-chain
guard keeps it a no-op on dev/localhost where the tracker isn't loaded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
oskar 2026-06-24 17:58:24 +02:00
parent b519b49e0d
commit 144dff7f85

View file

@ -3,6 +3,13 @@ import { motion } from 'framer-motion';
import { Mail, MessageSquare } from 'lucide-react';
import { useT } from '../i18n';
declare global {
interface Window {
// Injected by the Umami script (production builds only — see vite.config.ts).
umami?: { track: (event: string) => void };
}
}
type Status = 'idle' | 'sending' | 'success' | 'error';
const CTASection = () => {
@ -72,6 +79,9 @@ const CTASection = () => {
return;
}
setStatus('success');
// Fire the Umami conversion goal only after a real 200 from the mailer.
// Guarded: the tracker is absent on dev/localhost, so this must not throw.
window.umami?.track('umow-rozmowe');
} catch {
setErrorMsg(t.contact.errors.generic);
setStatus('error');