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:
parent
b519b49e0d
commit
144dff7f85
|
|
@ -3,6 +3,13 @@ import { motion } from 'framer-motion';
|
||||||
import { Mail, MessageSquare } from 'lucide-react';
|
import { Mail, MessageSquare } from 'lucide-react';
|
||||||
import { useT } from '../i18n';
|
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';
|
type Status = 'idle' | 'sending' | 'success' | 'error';
|
||||||
|
|
||||||
const CTASection = () => {
|
const CTASection = () => {
|
||||||
|
|
@ -72,6 +79,9 @@ const CTASection = () => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setStatus('success');
|
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 {
|
} catch {
|
||||||
setErrorMsg(t.contact.errors.generic);
|
setErrorMsg(t.contact.errors.generic);
|
||||||
setStatus('error');
|
setStatus('error');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue