Bitrix24 Integration with Google Analytics

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

Bitrix24 Integration with Google Analytics

GA4 captures sessions and events on the site, Bitrix24 captures deals and revenue. Without integration, the marketer looks at GA4, the salesperson looks at the CRM, and they argue about whether advertising works. Integration provides a unified picture: from click to revenue.

Integration Architecture with GA4

Google Analytics 4 does not have an offline conversion mechanism in the form that exists in Yandex.Metrica. The primary method for sending deal data is GA4 Measurement Protocol.

Measurement Protocol allows sending events to GA4 from the server, without the user's browser. The event is linked to a session via the GA4 client_id (the _ga cookie parameter).

Scheme:

User visits site → JavaScript saves GA4 client_id to form
  → Lead is created in CRM with client_id
  → Deal moves to "Won"
  → Server sends purchase event to GA4 via Measurement Protocol
  → GA4 attributes revenue to traffic source

Getting GA4 client_id on the Site

// Wait for GA4 initialization
gtag('get', 'G-XXXXXXXX', 'client_id', (clientId) => {
    document.getElementById('ga_client_id').value = clientId;
});

A hidden ga_client_id field in the form — passed along with other data on submission. On the server it is saved in the CRM as a custom lead/deal field UF_CRM_GA_CLIENT_ID.

Sending an Event to GA4 via Measurement Protocol

When the deal moves to the "Won" stage, the server sends a POST request:

$measurementId = 'G-XXXXXXXX';
$apiSecret     = 'YOUR_API_SECRET'; // GA4 → Settings → Data Streams → Measurement Protocol API secrets

$payload = [
    'client_id' => $deal['UF_CRM_GA_CLIENT_ID'],
    'timestamp_micros' => (int)(microtime(true) * 1_000_000),
    'events' => [
        [
            'name'   => 'purchase',
            'params' => [
                'transaction_id' => 'DEAL_' . $deal['ID'],
                'value'          => (float)$deal['OPPORTUNITY'],
                'currency'       => $deal['CURRENCY_ID'],
                'items'          => array_map(fn($row) => [
                    'item_id'   => $row['PRODUCT_ID'],
                    'item_name' => $row['PRODUCT_NAME'],
                    'quantity'  => $row['QUANTITY'],
                    'price'     => $row['PRICE'],
                ], $dealProducts),
            ],
        ],
    ],
];

$url = "https://www.google-analytics.com/mp/collect?measurement_id={$measurementId}&api_secret={$apiSecret}";
$ch  = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_exec($ch);

The api_secret parameter is generated in the GA4 interface: Admin → Data Streams → [Stream] → Measurement Protocol API secrets.

Attribution Problems in GA4

Deal delay — the client clicked on an ad today, bought two weeks later. GA4 stores the session for 30 days (configurable). If client_id is saved in the CRM when the lead is created — there's no problem: the event is sent with the same client_id, GA4 attributes it to the correct session.

Expired client_id — GA4 cookies live for 2 years, but the user may have changed browsers, devices, or cleared cookies. For B2B deals with a long cycle this is a real problem. Solution: store multiple client_id values (from different visits) and pass all of them when sending the event — Measurement Protocol accepts an array of events with different client_id values.

Ad blockers — some users block gtag.js, client_id is not recorded. Data loss of 15–30% depending on the audience. Partial solution — Google Tag Manager via server-side tagging.

Audiences and Remarketing

After transferring offline conversions to GA4, audiences can be built:

  • Purchased for amount > N
  • Purchased a specific product category (via item_category in event parameters)
  • Purchased 2+ times (LTV segment)

Audiences from GA4 are passed to Google Ads for remarketing and Look-alike. This is the foundation for ROAS optimization of campaigns based on actual revenue, not just applications.

Real Case: Gap Between GA4 and CRM

Task: SaaS company, product with a three-week sales cycle. The marketer looked at GA4 — conversions (registrations) were growing. Management looked at the CRM — revenue was stagnating. The discrepancy couldn't be explained.

What was found: GA4 was counting registration as a conversion (micro-conversion), not payment. 70% of registrations were users who registered, tried the trial period and left. Ad optimization was targeting cheap registrations, not those who pay.

Solution: sending the purchase event with amount via Measurement Protocol when the deal moves to "Won." Plus a trial_started event on account creation and trial_converted on first payment.

Result: a funnel from first click to payment appeared in GA4. It turned out that organic search converts from trial to payment at 22%, while performance advertising converts at 8%. Budget was reallocated, ROAS increased by 35%.

Integration Timeframes

Task Time
Embedding client_id retrieval in site forms 1 day
Developing the Measurement Protocol handler 2–3 days
Configuring custom CRM automation for sending 1–2 days
Testing via GA4 DebugView and verification 1–2 days

Full integration — 1–2 weeks. Accumulating statistics for conclusions — 4–8 weeks.