Setting Up Dynamic Call Tracking on 1C-Bitrix
Dynamic call tracking solves one specific problem: identifying which advertising campaign or channel brought in a customer who called. Without it, the advertising report shows clicks and on-site conversions, but phone calls fall out of the picture. In e-commerce and service businesses where 40–60% of leads come via phone, this renders analytics useless.
The principle: each visitor is shown a unique substituted phone number from a pool. The call tracking system matches the number to the visit and records UTM parameters, traffic source, and keyword. After the call, the number is returned to the pool.
Choosing a Provider and Installing the Script
Major providers on the market: Callibri, CoMagic, Roistat, Ringostat, Mango Office. Each has its own JS script and API. Architecturally all of them work identically: insert the script in <head>, and it replaces phone numbers on the page using a CSS selector or a span with data attributes.
For Bitrix, add the script via the standard Bitrix\Main\Page\Asset mechanism:
// /local/php_interface/init.php
\Bitrix\Main\EventManager::getInstance()->addEventHandler(
'main',
'OnEpilog',
function () {
if (\Bitrix\Main\Application::getInstance()->getContext()->getRequest()->isAdminSection()) {
return;
}
$asset = \Bitrix\Main\Page\Asset::getInstance();
$asset->addString(
'<script type="text/javascript">
(function(w,d,n,t){
// Call tracking provider script code
w[n] = w[n] || function(){(w[n].q=w[n].q||[]).push(arguments)};
t = d.createElement("script");
t.async = 1;
t.src = "https://tracker.callibri.ru/callibri.js";
d.head.appendChild(t);
})(window,document,"callibri");
callibri("setCounter", "YOUR_COUNTER_ID");
</script>',
true // in head
);
}
);
Adding via OnEpilog ensures the script does not end up in the Bitrix page cache and is not inserted twice during AJAX navigation.
Phone Number Markup on the Site
For substitution to work correctly, phone numbers must be marked up. The recommended approach — data attributes on a span:
<!-- Instead of -->
<span class="phone">+7 (495) 123-45-67</span>
<!-- Use -->
<span class="calltracking-phone"
data-original-phone="+74951234567"
data-phone-display="+7 (495) 123-45-67">
+7 (495) 123-45-67
</span>
The provider script finds elements by class or attribute and replaces the content. If the phone number is output via Bitrix components (header, product card), make the change in the component template — typically header.php or a custom template.
For sites with multiple phone numbers (main, sales department, service) — each can be assigned a separate pool of numbers via substitution groups. Configured in the provider's control panel.
Configuring the Number Pool
Pool size determines tracking accuracy. Calculation: if the site has 20 concurrent visitors and the average session duration is 3 minutes, a minimum of 20 numbers is needed. Providers offer a recommendation based on traffic volume.
For Bitrix sites with caching there is a nuance: if the page is cached at the Bitrix level (managed cache or nginx), the call tracking script may load with a delay or not load at all when JS is disabled. Solution — include the phone number in the HTML as a fallback; substitution happens via JS after page load.
Passing Data to Google Analytics / Yandex.Metrica
Call tracking providers can send calls as events to GA4 and Metrica. To do so, specify the counter IDs in the provider settings. Additionally — pass User ID to stitch sessions:
// After initializing the GA4 counter
callibri('onCallStart', function(callData) {
gtag('event', 'phone_call_start', {
'call_id' : callData.callId,
'utm_source' : callData.utmSource,
'utm_campaign': callData.utmCampaign,
});
});
callibri('onCallEnd', function(callData) {
gtag('event', 'phone_call_end', {
'call_id' : callData.callId,
'duration' : callData.duration,
'is_target': callData.isTarget,
});
});
Verifying Correct Substitution
After installation, verify that substitution works for all channels. Checklist:
- Open the site with UTM parameters
?utm_source=yandex&utm_medium=cpc— the phone number should change - Open without UTM (direct visit) — the default pool number should be displayed
- Check cached pages: after warming the
bitrix:cache, the phone should still be substituted - Confirm that the phone in og:image and Schema.org (if present) is static and not subject to substitution
- Check the mobile version — click-to-call should dial the substituted number
Scope of Work
- Register account with the provider, configure the number pool
- Install the JS script in the Bitrix template via the Asset API
- Mark up phone numbers in component templates
- Configure substitution groups (if multiple phone numbers)
- Integrate with GA4 / Yandex.Metrica via events
- Test substitution across all traffic sources
Timelines: basic setup (one phone, one pool) — 3–5 business days. Complex configurations with multiple phones, groups, and CRM integration — 1–2 weeks.







