Integrating Hotjar with 1C-Bitrix
Hotjar records user sessions, builds click and mouse movement heatmaps, and collects on-page survey responses. For an online store built on 1C-Bitrix, it answers the question "what are users actually doing?" — something Yandex.Metrica alone doesn't explain. Installation is simpler than most analytics tools; the challenge is configuring it correctly for 1C-Bitrix specifics.
Installing the Tracking Code
<!-- In the Bitrix template, before </head> or before </body> -->
<script>
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid: YOUR_HJID, hjsv: 6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>
In 1C-Bitrix, add it via Settings → Product Settings → JS Snippets or directly in the template file. Use "before the closing </head>" — this ensures Hotjar starts loading as early as possible and does not miss the beginning of a session.
Identifying Authenticated Users
Hotjar supports user identification via hj('identify', userId, attributes). This allows filtering session recordings by attributes and building heatmaps only for specific segments.
<?php if ($USER->IsAuthorized()):
$userId = $USER->GetID();
$ordersCount = getUserOrdersCount($userId);
$totalSpent = getUserTotalSpent($userId);
$loyaltyLevel = getUserLoyaltyLevel($userId);
?>
<script>
window.hj = window.hj || function(){(hj.q=hj.q||[]).push(arguments)};
hj('identify', <?= $userId ?>, {
email: <?= json_encode($USER->GetEmail()) ?>,
orders_count: <?= $ordersCount ?>,
total_spent: <?= $totalSpent ?>,
loyalty_level: <?= json_encode($loyaltyLevel) ?>,
is_b2b: <?= getUserIsB2B($userId) ? 'true' : 'false' ?>,
});
</script>
<?php endif; ?>
Once configured, the Hotjar interface allows filtering recordings such as "show only sessions for users with orders_count > 5" or "only B2B users." This dramatically reduces analysis time.
Configuring Events for Heatmaps
By default, Hotjar builds heatmaps based on page URLs. This works correctly for static pages in 1C-Bitrix, but there are edge cases:
Faceted filter modifies the URL. catalog.smart.filter appends filter parameters to the URL — /catalog/electronics/filter/price-from-1000-to-5000/. Hotjar will create a separate heatmap for every filter combination. Solution: in Hotjar settings, create a URL grouping rule — "all URLs containing /catalog/electronics/filter/" are merged into one heatmap.
Pagination. /catalog/?PAGEN_1=2 generates a separate heatmap. Similarly — create a URL grouping rule for paginated pages.
Dynamic cart and checkout pages. sale.order.ajax changes page content without a URL change. Hotjar handles this correctly — recording DOM mutations. However, the heatmap shows clicks across all states of the page combined. Use session recordings to analyze specific checkout steps.
Sending Events to Hotjar
For marking key actions in session recordings:
// Add to cart
function onAddToCart(productId, productName) {
hj('event', 'add_to_cart');
hj('tagRecording', ['add_to_cart', 'product-' + productId]);
}
// Checkout started
hj('event', 'checkout_started');
// Error in checkout form
hj('event', 'checkout_form_error');
hj('tagRecording', ['checkout_error']);
tagRecording tags allow filtering recordings in Hotjar: "show only sessions with the checkout_error tag" — this instantly isolates problematic user paths.
Configuring Surveys on 1C-Bitrix
Hotjar Surveys requires no additional integration — it is configured entirely within the Hotjar interface using display conditions (URL, time on page, scroll depth). For 1C-Bitrix-specific scenarios:
Post-order survey. Condition: page /order/success/ or URL contains ?ORDER_ID=. Question: "What almost stopped you from placing an order?"
Abandoned cart survey. Condition: page /basket/, user is about to leave (exit intent). Question: "Didn't find what you were looking for?"
GDPR and Federal Law No. 152 Compliance
Hotjar records user sessions — this constitutes personal data. You must:
- Add Hotjar to the privacy policy
- Implement user consent (cookie banner)
- Initialize Hotjar only after consent is obtained:
// Initialize Hotjar only after consent
document.addEventListener('cookieConsentGiven', function() {
(function(h,o,t,j,a,r){ /* ... Hotjar code ... */ })();
});
In 1C-Bitrix, cookie consent is implemented via the standard bitrix:main.cookie.agreement component or a custom banner.
Excluding the Admin Area
Hotjar must not record sessions in /bitrix/admin/:
if (window.location.pathname.indexOf('/bitrix/admin') === -1 &&
window.location.pathname.indexOf('/area51') === -1) {
// Hotjar initialization
}
Scope of Work and Timelines
- Tracking code installation, cookie consent — 4–8 hours
- User identification, attribute transmission — 4 hours
- URL grouping rules configuration (filters, pagination) — 2–4 hours
- Event and recording tag setup — 4–8 hours
- First heatmap and recording analysis — 1–2 weeks after launch
Total integration time — 2–3 working days. Analysis and insights — an ongoing process, not a one-time task.







