This commit is contained in:
alexencom committed 2026-11-02 15:56:33 +03:00
1 parent b2a790337e
commit 527bbefc83
1 file changed
+13 -3
+13 -3
View File
@@ -1,5 +1,5 @@
// Analytics: use the existing Metrika counter and the supplied GTM container. // Analytics load only after consent: Metrika, GTM and direct GA4.
// A GTM- identifier is a Tag Manager container, not a GA4 measurement ID. // GA4 is configured here; do not configure the same GA4 tag/events again in GTM.
(function() { (function() {
const key = 'olyapka_analytics_v2'; const key = 'olyapka_analytics_v2';
const banner = document.getElementById('cookieBanner'); const banner = document.getElementById('cookieBanner');
@@ -16,6 +16,12 @@
document.head.append(metrika); document.head.append(metrika);
window.ym(110606131, 'init', {clickmap: true, trackLinks: true, accurateTrackBounce: true, webvisor: true}); window.ym(110606131, 'init', {clickmap: true, trackLinks: true, accurateTrackBounce: true, webvisor: true});
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
window.gtag = window.gtag || function() { window.dataLayer.push(arguments); };
window.gtag('js', new Date());
window.gtag('config', 'G-T6084CKB81');
const ga = document.createElement('script');
ga.async = true; ga.src = 'https://www.googletagmanager.com/gtag/js?id=G-T6084CKB81';
document.head.append(ga);
window.dataLayer.push({'gtm.start': Date.now(), event: 'gtm.js'}); window.dataLayer.push({'gtm.start': Date.now(), event: 'gtm.js'});
const gtm = document.createElement('script'); const gtm = document.createElement('script');
gtm.async = true; gtm.src = 'https://www.googletagmanager.com/gtm.js?id=GTM-M5HGH586'; gtm.async = true; gtm.src = 'https://www.googletagmanager.com/gtm.js?id=GTM-M5HGH586';
@@ -75,7 +81,11 @@
if (window.analyticsAllowed && typeof ym !== 'undefined') { if (window.analyticsAllowed && typeof ym !== 'undefined') {
try { ym(110606131, 'reachGoal', goal); } catch(err) {} try { ym(110606131, 'reachGoal', goal); } catch(err) {}
} }
// Google Analytics // Send existing button goals directly to GA4.
if (window.analyticsAllowed && typeof window.gtag === 'function') {
window.gtag('event', goal, {send_to: 'G-T6084CKB81'});
}
// Keep custom events available to the existing GTM container.
if (window.analyticsAllowed && window.dataLayer) window.dataLayer.push({event: goal}); if (window.analyticsAllowed && window.dataLayer) window.dataLayer.push({event: goal});
}); });
})(); })();