// 2. ИНИЦИАЛИЗАЦИЯ ЯНДЕКС.МЕТРИКИ (С жесткой фиксацией контекста url)
window.ym = window.ym || function() { (ym.a = ym.a || []).push(arguments) };
ym.l = 1 * new Date();
var yaScriptAsync = document.createElement('script');
yaScriptAsync.async = true;
yaScriptAsync.src = "https://yandex.ru";
document.head.appendChild(yaScriptAsync);
// Передаем точный URL без параметров, чтобы внутренний observer Метрики не сходил с ума
var currentUrl = window.location.protocol + '//' + window.location.hostname + window.location.pathname;
ym(113327894, 'init', {
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
webvisor: true
url: currentUrl
});
function removeAnalyticsListeners() {
window.removeEventListener('scroll', loadAnalytics);
window.removeEventListener('click', loadAnalytics);
window.removeEventListener('mousemove', loadAnalytics);
window.removeEventListener('touchstart', loadAnalytics);
}
window.addEventListener('scroll', loadAnalytics, { passive: true });
window.addEventListener('click', loadAnalytics, { passive: true });
window.addEventListener('mousemove', loadAnalytics, { passive: true });
window.addEventListener('touchstart', loadAnalytics, { passive: true });
window.addEventListener('load', function() {
setTimeout(loadAnalytics, 3000);
});