Skip to content

Web SDK

Behavioral analytics for your website, in one line.

A lightweight, privacy-focused JavaScript library that tracks page views, sessions and custom events — with built-in A/B testing — and streams it all into B2Metric IQ.

From zero to first event in three steps

Drop in one script tag, optionally tune it with data-attributes, or take full control with a manual init.

  • Install

    One line in your <head> — that's it

  • Configure

    Tune batching, event groups & debug via data-attributes

  • Initialize manually

    Full control with the b2mInit() promise

Everything you need to understand web behavior

Auto-tracking gives you a baseline the moment the script loads — then opt into exactly the event groups, experiments and custom events you need.

  • Auto-Tracking

    Page views, sessions & SPA nav, for free.

    The moment the script loads it tracks page views, builds a user fingerprint, manages sessions and follows single-page-app route changes — no code required.

  • Event Tracking

    Ten event groups. Activate only what you need.

    Opt into modular groups — core, ecommerce, search and more — so you collect exactly the signals that matter and nothing you don't.

  • Custom Events

    Go beyond the built-ins.

    Send your own custom events with arbitrary parameters to capture the interactions unique to your product.

  • A/B Testing & Experiments

    Assign, cache and attribute — automatically.

    A built-in client requests variant assignments from the experiments service, caches them on the device, and emits exposure events so behavior is attributed to the right variant.

  • Offline Queue

    Capture now, send when connected.

    Events recorded while the browser is offline are queued locally and flushed automatically once the connection returns.

  • Platform Integrations

    Drop into the stack you already run.

    First-class guides for WordPress and other platforms get the tracker live on existing sites without touching application code.

Configure once. Collect exactly what you need.

Every option is set on the script tag or passed to b2mInit(). Activate only the event groups that matter, tune batching, and point experiments wherever you run them.

  • apiKey · string · required — Your API key
  • apiUrl · string · Production URL — Collector API URL
  • batchSize · number · 10 — Batch send size
  • sendInterval · number · 5000 — Send interval (ms)
  • sessionTimeout · number · 30 — Session timeout (minutes)
  • eventGroups · string[] · ['core'] — Active event groups
  • debug · boolean · false — Debug mode
  • experimentApiUrl · string · /experiments/assign — A/B assignment endpoint
  • experimentCacheTtl · number · 86400000 — A/B cache TTL (ms)

One consistent shape for every event

Auto-tracked or custom, every event is sent in the same structured format — ready for funnels, retention and flows in B2Metric IQ.

  • Every event has an event_name, ISO event_date and unix event_timestamp.
  • A session_id and fingerprint-based user_id tie events to a visitor.
  • event_params and user_params carry your context as key/value pairs.

The full Web SDK reference

From getting started to A/B testing and platform integrations — every page in the B2Metric Academy Web SDK guide.

  1. 01Introduction
  2. 02Getting Started
  3. 03Technical Architecture
  4. 04Platform Integrations
  5. 05Event Tracking
  6. 06Auto-Tracking
  7. 07Custom Events
  8. 08A/B Testing & Experiments
  9. 09Advanced Features
  10. 10Configuration Reference
  11. 11Frequently Asked Questions
  12. 12Support & Contact

Ship your first insight today.

Add one script tag, paste your API key, and watch events arrive in B2Metric IQ in real time.