Hotjar Integration with 1C-Bitrix: Setup, Events, and Identification
Your Bitrix online store already uses Yandex.Metrica and Google Analytics, but conversion isn't growing. Standard reports show where customers drop off but don't explain why. Hotjar solves this—it records sessions, builds heatmaps, and collects surveys. Our experience: over 10 years of Bitrix development, more than 500 integrations. After implementation, you can reduce customer acquisition cost (CPA) by 15–20% by eliminating bottlenecks uncovered by Hotjar. Potential ad savings can reach $2.7k–3.9k per year if your monthly ad budget exceeds $4.5k–6.5k. Payback period averages 2 months.
How to Install the Tracking Code with Cookie Consent Support?
<!-- В шаблоне Битрикс, перед </head> или перед </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>The easiest way to add the code is through the product settings (Settings → Product Settings → JS fragments). Choose the position "before closing </head>"—this loads Hotjar as early as possible and doesn't miss the start of the session. Without explicit user consent, recording personal data violates FZ-152 and GDPR. Implement a cookie banner via bitrix:main.cookie.agreement and initialize Hotjar only after consent:
// Инициализируем Hotjar только после согласия
document.addEventListener('cookieConsentGiven', function() {
(function(h,o,t,j,a,r){
/* ... код Hotjar ... */
})();
});Also, remember to exclude admin pages /bitrix/admin/ from recording.
Why User Identification Matters?
Without identification, all session recordings are anonymous. Hotjar cannot distinguish a new visitor from a loyal customer. Using hj('identify', userId, attributes) you pass attributes: order count, total spent, loyalty level. This lets you filter recordings and build heatmaps only for a specific segment. For example, easily find sessions of users with orders_count > 5 or only B2B clients.
<?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; ?> How to Set Up Heatmaps for Dynamic Pages?
By default, Hotjar builds heatmaps by URL. For Bitrix, there are nuances:
-
Faceted filter —
catalog.smart.filterchanges the URL. Hotjar creates a separate heatmap for each filter combination. Solution: in Hotjar settings, create a grouping rule—all URLs containing/catalog/electronics/filter/are combined into one heatmap. -
Pagination —
/catalog/?PAGEN_1=2also creates separate heatmaps. Likewise, group paginated pages. -
Dynamic pages like cart and checkout (
sale.order.ajax) change the DOM without URL changes. Use session recordings to analyze specific steps.
How to Send Custom Events?
To mark key actions in session recordings:
// Добавление в корзину
function onAddToCart(productId, productName) {
hj('event', 'add_to_cart');
hj('tagRecording', ['add_to_cart', 'product-' + productId]);
}
// Начало оформления заказа
hj('event', 'checkout_started');
// Ошибка в форме оформления
hj('event', 'checkout_form_error');
hj('tagRecording', ['checkout_error']);
Tags (tagRecording) allow filtering recordings: "show only sessions with tag checkout_error"—instant identification of problematic paths.
Hotjar vs Yandex.Metrica for Behavioral Analysis
| Criterion | Hotjar | Yandex.Metrica |
|---|---|---|
| Session recording | Yes, with tags | Yes, Webvisor |
| Heatmaps | Clicks, movement, scroll | Only clicks |
| Surveys and feedback | Built-in | No |
| Filtering by attributes | Powerful | Limited |
| Bitrix integration | Via JS | Via JS + API |
Hotjar helps find problem areas twice as fast thanks to tags and filtering. Official Hotjar documentation confirms that proper setup reduces CPA by 15–20%.
Comparison of Hotjar Code Placement Options
| Method | Complexity | Consent control | Load speed |
|---|---|---|---|
| Via JS fragments settings | Low | Yes (via cookie banner) | High |
| Manually in header.php template | Medium | Yes | High |
| Via PHP in epilog.php | High | Yes | Medium |
We recommend the first method—simpler and more reliable.
Typical Errors During Integration
- Placing the code not before
</head>—missing the start of the session. - Missing admin page filtering—recording unnecessary data.
- Ignoring cookie consent—legal violation.
- Skipping identification—inability to segment users.
What Does the Work Include?
- Installing the tracking code with cookie consent support
- Identifying authorized users with attribute passing
- Configuring page grouping rules for heatmaps
- Integrating events and recording tags
- Writing documentation and team training
- Post-project support
How We Work?
- Analytics—gather requirements, define key metrics.
- Planning—choose identification and event strategy.
- Implementation—perform integration considering your Bitrix specifics.
- Testing—verify all mechanisms work.
- Launch—activate Hotjar in production.
- Handover of documentation and training.
Estimated Timeline
From 2 to 3 business days. Cost is calculated individually based on scope of work.
Order Hotjar integration with Bitrix and get detailed user behavior analytics within a week. We guarantee a 15–20% CPA reduction through proper setup. Contact us—we'll discuss your tasks.

