From b32e7da506d81374417fbf71c2b52764dac2ebf8 Mon Sep 17 00:00:00 2001 From: Yuriy Panov Date: Sat, 19 Sep 2026 22:08:29 +0600 Subject: [PATCH] Add the Top.Mail.Ru counter to all four landings with a lead goal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- fitnes/index.html | 95 ++++++++++++++++++++++++++------- fitnes/src/lib/lead.ts | 23 +++++++- hotel/index.html | 28 ++++++++++ hotel/src/lib/lead.ts | 23 +++++++- medcenterphysio/index.html | 28 ++++++++++ medcenterphysio/src/lib/lead.ts | 23 +++++++- medcenterstart/index.html | 28 ++++++++++ medcenterstart/src/lib/lead.ts | 23 +++++++- 8 files changed, 249 insertions(+), 22 deletions(-) diff --git a/fitnes/index.html b/fitnes/index.html index 86f08eb..6398d5b 100644 --- a/fitnes/index.html +++ b/fitnes/index.html @@ -2,7 +2,10 @@ - + EXO Recovery Zone для фитнес-клубов | Экзо Групп - - + + - + + + + + +
diff --git a/fitnes/src/lib/lead.ts b/fitnes/src/lib/lead.ts index b9bbb41..5f38702 100644 --- a/fitnes/src/lib/lead.ts +++ b/fitnes/src/lib/lead.ts @@ -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 { const params = new URLSearchParams(window.location.search) @@ -63,7 +66,10 @@ export async function submitLead(form: LeadFormId, values: Omit[] ym?: (counterId: number, action: string, ...args: unknown[]) => void + _tmr?: Record[] } } diff --git a/hotel/index.html b/hotel/index.html index 7ddee53..f812965 100644 --- a/hotel/index.html +++ b/hotel/index.html @@ -74,11 +74,39 @@ }) + + + + +
diff --git a/hotel/src/lib/lead.ts b/hotel/src/lib/lead.ts index cccd595..07df2b0 100644 --- a/hotel/src/lib/lead.ts +++ b/hotel/src/lib/lead.ts @@ -12,6 +12,9 @@ const DRAFT_KEY = 'exo_hotel_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 { const params = new URLSearchParams(window.location.search) @@ -66,7 +69,10 @@ export async function submitLead( window.dataLayer = window.dataLayer ?? [] window.dataLayer.push({ event: 'hotel_lead_sent', form }) // 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) { @@ -102,6 +108,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) + } +} + /* -------------------------------------------------------------------------- */ /* Клик по кнопке звонка */ /* -------------------------------------------------------------------------- */ @@ -176,5 +196,6 @@ declare global { interface Window { dataLayer?: Record[] ym?: (counterId: number, action: string, ...args: unknown[]) => void + _tmr?: Record[] } } diff --git a/medcenterphysio/index.html b/medcenterphysio/index.html index de7c9cb..f5219f7 100644 --- a/medcenterphysio/index.html +++ b/medcenterphysio/index.html @@ -73,11 +73,39 @@ }) + + + + +
diff --git a/medcenterphysio/src/lib/lead.ts b/medcenterphysio/src/lib/lead.ts index 340fc76..9a76a58 100644 --- a/medcenterphysio/src/lib/lead.ts +++ b/medcenterphysio/src/lib/lead.ts @@ -12,6 +12,9 @@ const DRAFT_KEY = 'exo_medcenter_lead_draft' /** Тот же счётчик, что и в инлайн-снипете index.html — один на все четыре лендинга. */ const METRIKA_ID = 112352796 +/** Счётчик Top.Mail.Ru — тот же, что в инлайн-снипете index.html. */ +const TMR_ID = '3795059' + const FALLBACK_ERROR = 'Не удалось отправить форму автоматически. Данные сохранены в браузере — свяжитесь с нами по +7 927 789-60-71.' @@ -66,7 +69,10 @@ export async function submitLead( window.dataLayer = window.dataLayer ?? [] window.dataLayer.push({ event: 'medcenter_lead_sent', form }) // 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) { @@ -98,6 +104,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) + } +} + /* -------------------------------------------------------------------------- */ /* Клик по кнопке звонка */ /* -------------------------------------------------------------------------- */ @@ -172,5 +192,6 @@ declare global { interface Window { dataLayer?: Record[] ym?: (counterId: number, action: string, ...args: unknown[]) => void + _tmr?: Record[] } } diff --git a/medcenterstart/index.html b/medcenterstart/index.html index d4556f6..a0a8d63 100644 --- a/medcenterstart/index.html +++ b/medcenterstart/index.html @@ -73,11 +73,39 @@ }) + + + + +
diff --git a/medcenterstart/src/lib/lead.ts b/medcenterstart/src/lib/lead.ts index bc96a09..238d96e 100644 --- a/medcenterstart/src/lib/lead.ts +++ b/medcenterstart/src/lib/lead.ts @@ -12,6 +12,9 @@ const DRAFT_KEY = 'exo_medcenter_no_physio_lead_draft' /** Тот же счётчик, что и в инлайн-снипете index.html — один на все четыре лендинга. */ const METRIKA_ID = 112352796 +/** Счётчик Top.Mail.Ru — тот же, что в инлайн-снипете index.html. */ +const TMR_ID = '3795059' + const FALLBACK_ERROR = 'Не удалось отправить форму автоматически. Данные сохранены в браузере — свяжитесь с нами по +7 927 789-60-71.' @@ -66,7 +69,10 @@ export async function submitLead( window.dataLayer = window.dataLayer ?? [] window.dataLayer.push({ event: 'medcenter_no_physio_lead_sent', form }) // 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) { @@ -98,6 +104,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) + } +} + /* -------------------------------------------------------------------------- */ /* Клик по кнопке звонка */ /* -------------------------------------------------------------------------- */ @@ -172,5 +192,6 @@ declare global { interface Window { dataLayer?: Record[] ym?: (counterId: number, action: string, ...args: unknown[]) => void + _tmr?: Record[] } } -- 2.54.0