📄️ Introduction
The B2Metric Web SDK is a lightweight, privacy-focused JavaScript library that tracks visitor behavior on your website with a single script tag. It automatically captures page views, sessions, clicks, scroll depth, and e-commerce activity, works with dataLayer/GTM setups you already have, and stays out of the way until your consent platform allows it to send data.
📄️ Getting Started
Basic Integration (Recommended)
📄️ How Events Are Enriched
Device & Identity
📄️ Platform Integrations
WordPress
📄️ Google Tag Manager
If you use GTM, your dataLayer is usually already populated to some degree, so setting up GTM answers two questions at once: how to load the tag, and which tracking mode to use.
📄️ GA4 / dataLayer Tracking Modes
If your site already pushes events to a dataLayer (typically for GA4), the SDK can read from it instead of — or alongside — collecting its own events. Set this with data-tracking-mode (or trackingMode in b2mConfig). Unrecognized or empty values silently fall back to native, so a typo in the mode name won't throw an error — it just won't behave as expected.
📄️ Event Tracking
The SDK ships with several event groups; enable only the ones you need (see Configuration Reference for the full list and defaults).
📄️ Auto-Tracking
Automatically Tracked Events (Default-On Groups)
📄️ Custom Events
You can send your own events beyond the built-in ones. A script tag alone isn't enough for this — custom event names must be declared in an event group, or they're silently dropped:
📄️ Identity & Login Integration
Device identity is automatic (see How Events Are Enriched). For a logged-in site, pair it with your own login system using b2mSetUserId — this is what lets B2Metric merge a visitor's activity across devices and keep A/B test assignment consistent per account.
📄️ A/B Testing
Assignment API
📄️ Consent Management (GDPR / KVKK)
With requireConsent enabled, nothing is sent until consent is given — not even on page close. Events are held in a queue; giveConsent() flushes it, revokeConsent() discards whatever hasn't been sent yet.
📄️ Chat Widget Integration
Fill in INTEGRATIONID and CHATAPI_KEY (provided by B2Metric) and TENANT, your preset name — without it the widget opens unbranded, in English (alternatively, supply data-chat-config-url).
📄️ Session Replay
Off by default. To enable:
📄️ Multi-Domain / Multi-Brand Setup
cookieDomain="auto" (the default) shares UTM/campaign/referrer data and device identity across your subdomains as visitors move between them.
📄️ Embedding as an iframe Widget
If you embed your own widget as an iframe on third-party sites and want to track interactions inside it:
📄️ Virtual Try-On (Pulpo AR) Integration
If your storefront uses the PulpoAR try-on widget:
📄️ Combining Multiple Features
Attributes are additive. For example, e-commerce + chat + consent in a single tag:
📄️ Advanced Features
Offline Queue
📄️ Configuration Reference
Configuration Options
📄️ Post-Integration Verification
After installing, confirm the setup from your browser console:
📄️ Frequently Asked Questions
Technical Questions
📄️ Support & Contact
| Channel | Contact |