Web Analytics Setup on 1C-Bitrix
A standard 1C-Bitrix installation does not connect analytics counters automatically — a developer must place Google Analytics and Yandex.Metrica codes manually, otherwise traffic data simply will not be collected. A common mistake is inserting the code directly into a template without accounting for page caching: the counter ends up in the cache and is served incorrectly, especially when the cache module is active.
Correct placement of counter codes
In 1C-Bitrix, analytics codes are placed via the bitrix:main.include component or directly in the header.php / footer.php file of the site template. It is critical to place them outside cacheable blocks.
In header.php:
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die();?>
Counter codes are placed outside calls to $APPLICATION->ShowHead(), in a zone not wrapped in $APPLICATION->StartResultCache(). If the template uses .section.php, ensure that <head> is not cached via BXEditorUtils::StartEditSection().
Google Tag Manager is the preferred approach: one GTM container in <head> and one at the start of <body>, with all counters managed from the GTM interface without editing the template.
Setup via the "Web Analytics" module
1C-Bitrix ships with a built-in statistic module. It collects hits into the b_stat_adv_guest table and sessions into b_stat_session, but this is not used for external systems (GA4, Metrica). For GA4 and Metrica, integration is done through template settings or the iblock.social.network module.
In the admin panel: Settings → Product Settings → Sites — here you can enter a Metrica counter ID in the STAT_SITE_ID field, however this mechanism is outdated and does not support modern counter versions.
Verifying correct installation
After placing the code, verify using browser developer tools:
- Network tab — request to
mc.yandex.ru/watch/XXXXXXXXmust return 200 - For GA4 — request to
google-analytics.com/g/collecton each page view - Google Tag Assistant extension marks the container green
With 1C-Bitrix caching enabled, it is important to check the counter not only on the homepage (which is often not cached), but also on catalog pages and product cards.
What is included in the setup
- Placement of GTM, GA4 and Yandex.Metrica codes in the template with cache handling
- Configuration of basic parameters: cross-domain tracking, administrator IP exclusion
- Verification of firing on all page types of the site
- Configuration of internal traffic filtering in GA4 and Metrica







