Development of Pop-Up Modules for 1C-Bitrix
A pop-up that appears at wrong time — annoying. The same pop-up appearing right moment with relevant offer — brings subscribers and sales. Difference — in triggers, targeting, and technical execution. Bitrix has no built-in pop-up constructor. Marketplace solutions usually overloaded and conflict with composite cache. Custom development gives full control: what to show, to whom, when, and how often.
Display Triggers
Trigger — event initiating pop-up show. Technically, each trigger — JavaScript handler calling modal window show function.
Exit-intent — mouse cursor moves to top viewport border. Tracked via mouseleave on document.documentElement. Works only desktop. On mobile, analog — scroll up page (user reaching address bar). Detected via touchmove analyzing direction:
document.addEventListener('mouseleave', (e) => {
if (e.clientY < 10) showPopup('exit-intent');
});
Scroll depth — user scrolled 50%, 70%, to page bottom. Use IntersectionObserver on marker element positioned in needed place, or calculate percentage via window.scrollY / (document.body.scrollHeight - window.innerHeight).
Time on page — setTimeout with 15-30 second delay. Simplest trigger.
Inactivity — user not moving mouse and not scrolling N seconds. Implemented via debounce-timer, reset on mousemove, scroll, keydown.
Element click — specific button or link. Standard addEventListener('click').
Viewed pages count — counter in sessionStorage. Increment on each pageview; on threshold reach — show.
Targeting: Who to Show
Pop-up without targeting — spam. Show conditions checked on server (generating config) and on client (trigger firing).
Server Conditions (formed in PHP-component):
- User group: authorized / guest / specific group. Checked via
$USER->GetUserGroupArray(). - Site section: show in catalog only, main only, exclude cart. Checked by
$APPLICATION->GetCurDir(). - Device type: desktop / mobile. Determined by User-Agent or
\Bitrix\Main\Service\MicroService\BaseSender(if Bitrix analytics connected). - UTM-tags: show pop-up only visitors from ad campaign. Checked
$_GET['utm_source']saving to session.
Client Conditions:
- Show frequency: no more once daily / per session / per N visits. Controlled via
localStoragewith last show timestamp. - Close: if user closed pop-up — don't show again. Record flag
popup_{id}_closedinlocalStorage.
Architecture: Component + iblock
Pop-ups conveniently managed via iblock. Each element — separate pop-up with settings:
| Property | Type | Purpose |
|---|---|---|
| TRIGGER_TYPE | List | exit-intent, scroll, timeout, inactivity |
| TRIGGER_VALUE | String | Scroll %, delay seconds |
| TARGET_PAGES | String | URL mask: /catalog/, /, exclusions |
| TARGET_GROUPS | Binding | User groups |
| SHOW_FREQUENCY | List | once, daily, session |
| POPUP_TEMPLATE | List | Template: subscribe, promo, feedback |
| CONTENT | HTML | Pop-up content |
| ACTIVE_FROM / ACTIVE_TO | Date | Activity period |
Component local:popup.manager included in header.php (or site template). Selects active pop-ups, filters by server conditions, forms JSON-config that JavaScript uses for trigger initialization.
Composite Cache Compatibility
Composite cache caches HTML. If pop-up config hardcoded in HTML — cached page shows stale set. Standard Bitrix solution: dynamic area \Bitrix\Main\Page\Frame or endpoint export.
AJAX preferred: on page load JavaScript requests /ajax/popup_config.php, gets JSON with active pop-ups array and settings. Page fully cached, config always fresh.
Minus — extra HTTP request. Practice shows 1-3 KB, executes in 20-50 ms, unnoticeable for user.
Typical Templates
Email subscription. Form with one field (email) and button. Submit via AJAX to handler adding email to Bitrix mailing list (\Bitrix\Sender\Internals\Model\PostingRecipientTable) or external service API (Mailchimp, Unisender). Mandatory: double opt-in for compliance with ФЗ-152 / GDPR.
Promo code. Show discount code, copy on click. Code from sale module coupons — \Bitrix\Sale\Internals\DiscountCouponTable. Pop-up may generate unique coupon per visitor (binding to FUSER_ID).
Callback. Form: name + phone. Submit creates lead in CRM Bitrix24 via REST API (crm.lead.add) or records in local iblock for manual processing.
Analytics of Shows
Without analytics unclear if pop-up works. Minimum — three metrics: shows, closes, conversions (target action). Data sent to Yandex.Metrica / Google Analytics via ym(COUNTER_ID, 'reachGoal', 'popup_show_' + popupId) or to own table b_popup_stats.
Timelines
| Variant | Contents | Timeline |
|---|---|---|
| One pop-up | Fixed trigger, one template, no admin management | 2-3 days |
| Constructor | iblock, several triggers, targeting, composite compatibility, analytics | 7-12 days |







