analytics: count a successful form as the FORM_SUCCESS Metrika goal

The counter was in place but nothing reached it: src/lib/lead.ts only pushed
a custom dataLayer event, which Metrika's ecommerce: 'dataLayer' ignores, so
form conversions were not counted at all.

All five forms — including the fitnes callback modal — funnel through the one
success branch in submitLead(), so a single ym(112352796, 'reachGoal',
'FORM_SUCCESS') per landing covers every one of them. The counter id is
hardcoded to match the inline snippet in index.html; two sources for it would
drift. The call is optional-chained and wrapped in try/catch, because losing
analytics must never cost a lead.

The honeypot is the one success that is not a conversion: the server answers
bots with 200 {ok:true, leadId:0} so they learn nothing, and leadId === 0 is
what keeps that answer out of the goal.

The goal itself still has to be created in the counter's settings as a
JavaScript event named FORM_SUCCESS — noted in deploy/README.md, replacing
the entry that said conversions were unwired.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Yuriy Panov
2026-09-09 01:30:47 +06:00
co-authored by Claude Opus 5
parent e13854e918
commit 8af2e463b3
5 changed files with 86 additions and 4 deletions
+6 -4
View File
@@ -243,8 +243,10 @@ Also enable reg.ru VPS snapshots — a full-image restore beats rebuilding under
- **One Metrika counter for four domains.** All four landings carry the same
Yandex.Metrika counter (`112352796`) in `index.html`, so reports mix the domains and
every domain has to be listed in the counter's settings, or its hits get filtered.
- **Still open before launch** (not deployment blockers): conversions are not wired to
Metrika goals — `src/lib/lead.ts` pushes a plain custom `dataLayer` event, which
Metrika's `ecommerce: 'dataLayer'` does not read, so a JS goal or an explicit
`ym(..., 'reachGoal', ...)` call is still needed; and the forms show implicit 152-ФЗ
- **The `FORM_SUCCESS` goal has to exist in the Metrika UI.** `src/lib/lead.ts` fires
`ym(112352796, 'reachGoal', 'FORM_SUCCESS')` on every successful form submission, but
the goal itself is not part of the code: create it in the counter's settings as
«JavaScript-событие» with the identifier `FORM_SUCCESS`, or the hits arrive and no
report ever shows them. The honeypot answer (`leadId: 0`) deliberately does not count.
- **Still open before launch** (not a deployment blocker): the forms show implicit 152-ФЗ
consent text with no link to a published privacy policy.