Setting Up Goals and Events in Google Analytics on 1C-Bitrix
GA4 has completely dropped classic "goals" in favor of events — a conversion is now any event marked as a key event. On 1C-Bitrix sites, the main conversion points are: order placement, form submission, a call via call tracking, and adding to cart. The problem is that standard 1C-Bitrix components do not generate GA4 events out of the box — manual integration via dataLayer is required.
Architecture via dataLayer and GTM
The correct approach is not to insert gtag() calls directly into PHP templates, but to push events through dataLayer in JavaScript, while GTM triggers listen to that array.
In the order component template sale.order.ajax (in result_modifier.php or the template's JS file):
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': '<?= $arResult['ORDER_ID'] ?>',
'value': <?= $arResult['PRICE'] ?>,
'currency': '<?= $arResult['CURRENCY'] ?>',
'items': []
}
});
For feedback forms, the bitrix:main.feedback component fires an event after submission via BX.onCustomEvent('onWebFormSuccess', ...). Subscribe to it:
BX.addCustomEvent('onWebFormSuccess', function(form) {
dataLayer.push({ event: 'form_submit', form_id: form.data.FORM_ID });
});
Key events for an online store
| GA4 Event | Trigger in 1C-Bitrix | Component |
|---|---|---|
view_item |
Product card load | catalog.element |
add_to_cart |
Click "Add to cart" | catalog.element, catalog.section |
begin_checkout |
Navigate to checkout | sale.basket.basket |
purchase |
Order successfully created | sale.order.ajax |
generate_lead |
Form submission | bitrix:main.feedback |
Passing product data
For add_to_cart an items array must be passed. Product data is available in the component template via $arResult['ITEM_PRICES'] and $arResult['PROPERTIES']. Build the JSON in result_modifier.php and pass it to a global variable:
$APPLICATION->AddHeadScript(
'<script>window.__itemData = ' . CUtil::PhpToJSObject($itemData) . ';</script>'
);
GTM configuration
In GTM, create a tag of type "Google Analytics: GA4 Event", with a trigger — Custom Event whose name matches the event field in dataLayer. Data Layer Variable type variables pull the required fields (ecommerce.value, ecommerce.transaction_id).
What we configure
-
dataLayer.push()instrumentation for all key events: cart, checkout, form submission - GTM container with tags and triggers for GA4
- Debugging via GA4 DebugView and GTM Preview Mode
- Marking
purchaseandgenerate_leadevents as conversions in the GA4 interface

