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.
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.
<!-- Add to your site's <head> -->
<script
src="https://tracker-fr-test.b2metric.com/b2m-web-sdk.js"
data-apiKey="YOUR_API_KEY">
</script>Quick start
Drop in one script tag, optionally tune it with data-attributes, or take full control with a manual init.
<!-- Add to your site's <head> -->
<script
src="https://tracker-fr-test.b2metric.com/b2m-web-sdk.js"
data-apiKey="YOUR_API_KEY">
</script>Capabilities
Auto-tracking gives you a baseline the moment the script loads — then opt into exactly the event groups, experiments and custom events you need.
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.
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.
Go beyond the built-ins.
Send your own custom events with arbitrary parameters to capture the interactions unique to your product.
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.
Capture now, send when connected.
Events recorded while the browser is offline are queued locally and flushed automatically once the connection returns.
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.
Configuration
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| apiKeyREQ | 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) |
<script
src="https://tracker-fr-test.b2metric.com/b2m-web-sdk.js"
data-apiKey="YOUR_API_KEY"
data-event-groups="core,ecommerce">
</script>Event data format
Auto-tracked or custom, every event is sent in the same structured format — ready for funnels, retention and flows in B2Metric IQ.
{
"event_name": "page_view",
"event_date": "2025-01-15T10:30:00.000Z",
"event_timestamp": 1736936200,
"session_id": "session_1736936000_abc12345",
"user_id": "fp_abc123def456...",
"event_params": [
{ "key": "page_url", "value": "https://example.com" },
{ "key": "page_title", "value": "Home" }
],
"user_params": [
{ "key": "fingerprint_id", "value": "abc123..." },
{ "key": "user_agent", "value": "Mozilla/5.0..." },
{ "key": "screen_resolution", "value": "1920x1080" }
]
}Documentation
From getting started to A/B testing and platform integrations — every page in the B2Metric Academy Web SDK guide.
Add one script tag, paste your API key, and watch events arrive in B2Metric IQ in real time.
Copyright © 2025 B2Metric | All Rights Reserved
Copyright © 2025 B2Metric | All Rights Reserved
Copyright © 2025 B2Metric | All Rights Reserved
Check your network and try again.