Add the Top.Mail.Ru counter to all four landings with a lead goal

The counter (id 3795059) was only in fitnes and only counted pageViews.
Carry the snippet over to hotel, medcenterstart and medcenterphysio — the
same counter serves all four, as the Metrika one already does — and fire
goal 'form' from submitLead(), the single place both the request form and
the callback dialog pass through.

The goal sits inside the existing `leadId !== 0` guard: that response is
the honeypot decoy, so a bot submission must not register a conversion,
in Top.Mail.Ru no more than in Metrika.

The noscript pixel goes in the body next to the Metrika one, per 9af36cc;
the fitnes one, added in the head, moves down to join it.

Note that fitnes/index.html also carries a Prettier pass over the whole
file — the reflowed Metrika block is formatting only, no behaviour change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-19 22:08:29 +06:00
co-authored by Claude Opus 5
parent da93bbc9f3
commit b32e7da506
8 changed files with 249 additions and 22 deletions
+22 -1
View File
@@ -12,6 +12,9 @@ const DRAFT_KEY = 'exo_fitness_lead_draft'
/** Тот же счётчик, что и в инлайн-снипете index.html — один на все четыре лендинга. */
const METRIKA_ID = 112352796
/** Счётчик Top.Mail.Ru — тот же, что в инлайн-снипете index.html. */
const TMR_ID = '3795059'
/** Query-string UTM tags, forwarded to amoCRM with the lead. */
function collectUtm(): Record<string, string> {
const params = new URLSearchParams(window.location.search)
@@ -63,7 +66,10 @@ export async function submitLead(form: LeadFormId, values: Omit<LeadInput, 'form
window.dataLayer = window.dataLayer ?? []
window.dataLayer.push({ event: 'fitness_lead_sent', form, configuration: values.configuration })
// leadId === 0 — ответ-обманка ханипота: сделки в amoCRM нет, конверсии тоже.
if (body.leadId !== 0) reachGoal('FORM_SUCCESS')
if (body.leadId !== 0) {
reachGoal('FORM_SUCCESS')
tmrReachGoal('form')
}
localStorage.removeItem(DRAFT_KEY)
return { ok: true }
} catch (error) {
@@ -99,6 +105,20 @@ function reachGoal(goal: string) {
}
}
/**
* Цель Top.Mail.Ru. `_tmr` — обычная очередь-массив: пуши, сделанные до загрузки
* code.js, счётчик разбирает сам, поэтому ждать загрузку не нужно.
*/
function tmrReachGoal(goal: string) {
try {
window._tmr = window._tmr ?? []
window._tmr.push({ type: 'reachGoal', id: TMR_ID, goal })
} catch (error) {
// Аналитика не имеет права ломать отправку формы.
console.warn('Top.Mail.Ru reachGoal failed', error)
}
}
/* -------------------------------------------------------------------------- */
/* Клик по кнопке звонка */
/* -------------------------------------------------------------------------- */
@@ -173,5 +193,6 @@ declare global {
interface Window {
dataLayer?: Record<string, unknown>[]
ym?: (counterId: number, action: string, ...args: unknown[]) => void
_tmr?: Record<string, unknown>[]
}
}