Bitrix24 Integration with Yandex.Metrica

Our company is engaged in the development, support and maintenance of Bitrix and Bitrix24 solutions of any complexity. From simple one-page sites to complex online stores, CRM systems with 1C and telephony integration. The experience of developers is confirmed by certificates from the vendor.
Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1177
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    811
  • image_bitrix-bitrix-24-1c_development_of_an_online_appointment_booking_widget_for_a_medical_center_594_0.webp
    Development based on Bitrix, Bitrix24, 1C for the company Development of an Online Appointment Booking Widget for a Medical Center
    564
  • image_bitrix-bitrix-24-1c_mirsanbel_458_0.webp
    Development based on 1C Enterprise for MIRSANBEL
    747
  • image_crm_dolbimby_434_0.webp
    Website development on CRM Bitrix24 for DOLBIMBY
    655
  • image_crm_technotorgcomplex_453_0.webp
    Development based on Bitrix24 for the company TECHNOTORGKOMPLEKS
    976

Bitrix24 Integration with Yandex.Metrica

Yandex.Metrica shows traffic, Bitrix24 shows deals. Between them — a gap: it's unclear which exact visits convert into revenue. The integration closes this gap and allows optimizing advertising by real sales, not just by applications.

Two Levels of Integration

First level: offline conversion transfer — sending deal data from Bitrix24 to Yandex.Metrica as offline conversions. Metrica enriches the data: you can see which sources and campaigns brought the clients who actually purchased.

Second level: ClientID in CRM — recording _ym_uid (Metrica ClientID) in a deal field when a lead is created. Allows opening a specific session in Metrica directly from the CRM and seeing the client's complete path on the site.

Sending Offline Conversions to Yandex.Metrica

Scheme: when a deal moves to the "Won" stage, data is sent to Metrica via the offline conversions API.

Metrica accepts offline conversions via POST /upload/v1/counter/{counterId}/goals/upload. Request format:

{
  "Hits": [
    {
      "ClientId": "{{ client's _ym_uid }}",
      "DateTime": "2026-03-13T10:00:00",
      "Target": "deal_won",
      "Price": 150000,
      "Currency": "RUB"
    }
  ]
}

Implementation via custom CRM automation (see the article on custom automation development): when transitioning to the "Won" stage, the automation reads the ClientID field from the deal and forms a request to the Metrica API.

Authorization in the Metrica API: OAuth token with metrika:write permissions. The token is stored in the module settings or in environment variables on the server.

Writing ClientID to the Deal

This is the key part that needs to be implemented on the site when submitting a form. JavaScript collects _ym_uid from the cookie:

function getYmClientId() {
    const match = document.cookie.match(/_ym_uid=([^;]+)/);
    return match ? match[1] : null;
}

// When submitting the form
const formData = {
    name: document.getElementById('name').value,
    phone: document.getElementById('phone').value,
    ym_client_id: getYmClientId(),
    // ... other fields
};

On the server when creating a lead via REST API:

$client->call('crm.lead.add', [
    'fields' => [
        'TITLE'                   => 'Website application',
        'UF_CRM_YM_CLIENT_ID'     => $formData['ym_client_id'],
        'UTM_SOURCE'              => $_GET['utm_source'] ?? '',
        'UTM_CAMPAIGN'            => $_GET['utm_campaign'] ?? '',
        // ...
    ],
]);

The UF_CRM_YM_CLIENT_ID field is created manually in the CRM settings: a string field on the lead and deal. When converting a lead to a deal, the field is copied (if configured correctly — see the lead sources article).

The Multi-Touch Attribution Problem

Metrica by default uses last-click attribution. For correctly calculating the value of advertising channels, this leads to undervaluing brand campaigns (which build demand but don't close conversions) and overvaluing retargeting.

With offline conversions the situation improves: Metrica knows the actual revenue per channel, not just the number of applications. But the attribution model is only changed through Yandex.Direct — there you can select "conversion share" or "conversion value" as a strategy.

Audience Synchronization

Metrica allows creating audience segments based on offline conversions: "clients who paid more than 100,000 RUB," "clients who purchased 2+ times." These audiences are passed to Yandex.Direct as Look-alike or for retargeting.

Creating a segment: Metrica → Audiences → Upload Data → Offline Conversions. Select the deal_won goal, build the segment. Export to Direct.

Real Case: Optimizing Paid Search by Revenue

Task: B2B consumables online store. Applications from paid search were coming in, but some turned out to be "junk" — individuals, off-target regions. Campaigns were being optimized by number of applications, but actual revenue wasn't growing.

Solution: offline conversions with deal amount transferred to Metrica. Set up transfer of two events: lead_qualified (when a lead is qualified by a manager) and deal_won (on deal win with amount).

What was found: out of three Direct campaigns, the "general keywords" campaign generated 40% of applications but only 10% of revenue. The "competitor brand" campaign generated 15% of applications and 35% of revenue. Without offline conversions this was invisible.

Result: budget was reallocated, CPA by revenue decreased by 28% in two months.

Integration Timeframes

Task Time
Implementing ClientID transfer from site forms 1–2 days
Developing custom automation for sending to Metrica 2–3 days
Setting up audience segments in Metrica 1 day
Testing the chain and data verification 1–2 days

Full integration — 1–2 weeks accounting for testing data transfer accuracy.