fix: add tracking service

This commit is contained in:
2025-06-20 12:47:57 +03:00
parent 2d77844758
commit 29a1abea03
7 changed files with 52 additions and 7 deletions

View File

@@ -6,3 +6,4 @@ export { OfferForm } from './offer-form';
export { OfferRequestForm } from './offer-request';
export { AdvancedPhoneInput } from './advanced-phone-input';
export { CookieNotice } from './cookie-notice';
export { YandexMetrika } from './yandex-metrika';

View File

@@ -0,0 +1 @@
export { default as YandexMetrika } from './ui';

View File

@@ -0,0 +1,31 @@
'use client';
import { usePathname } from 'next/navigation';
import { useEffect } from 'react';
import ym, { YMInitializer } from 'react-yandex-metrika';
import { YM_COUNTER_ID } from '@core/constants/tracking-service';
export default function YandexMetrika() {
const pathname = usePathname();
// Отправляем событие "hit" при изменении маршрута
useEffect(() => {
if (pathname) {
ym('hit', pathname);
}
}, [pathname]);
return (
<YMInitializer
accounts={[YM_COUNTER_ID]}
options={{
defer: true,
webvisor: true,
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
}}
version='2'
/>
);
}