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
+28
View File
@@ -73,11 +73,39 @@
})
</script>
<!-- /Yandex.Metrika counter -->
<!-- Top.Mail.Ru counter -->
<script type="text/javascript">
var _tmr = window._tmr || (window._tmr = [])
_tmr.push({ id: '3795059', type: 'pageView', start: new Date().getTime() })
;(function (d, w, id) {
if (d.getElementById(id)) return
var ts = d.createElement('script')
ts.type = 'text/javascript'
ts.async = true
ts.id = id
ts.src = 'https://top-fwz1.mail.ru/js/code.js'
var f = function () {
var s = d.getElementsByTagName('script')[0]
s.parentNode.insertBefore(ts, s)
}
if (w.opera == '[object Opera]') {
d.addEventListener('DOMContentLoaded', f, false)
} else {
f()
}
})(document, window, 'tmr-code')
</script>
<!-- /Top.Mail.Ru counter -->
</head>
<body>
<noscript
><div><img src="https://mc.yandex.ru/watch/112352796" style="position: absolute; left: -9999px" alt="" /></div
></noscript>
<noscript
><div>
<img src="https://top-fwz1.mail.ru/counter?id=3795059;js=na" style="position: absolute; left: -9999px" alt="Top.Mail.Ru" /></div
></noscript>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
+22 -1
View File
@@ -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<string, unknown>[]
ym?: (counterId: number, action: string, ...args: unknown[]) => void
_tmr?: Record<string, unknown>[]
}
}