Skip to content

feat: Measure ad-block rate via control domain init signal#61

Merged
mattbodle merged 1 commit intodevelopmentfrom
feat/adblock-measurement-v2
Mar 12, 2026
Merged

feat: Measure ad-block rate via control domain init signal#61
mattbodle merged 1 commit intodevelopmentfrom
feat/adblock-measurement-v2

Conversation

@mattbodle
Copy link
Collaborator

@mattbodle mattbodle commented Mar 10, 2026

Summary

  • Fire two hidden iframes from the mParticle kit during launcher initialization to measure ad-block rates by comparing signal counts server-side
  • Signal 1: existing domain (e.g. apps.rokt.com) — may be blocked by ad blockers
  • Signal 2: apps.roktecommerce.com (control domain) — not on any block lists
  • Signals fire from initRoktLauncher (after launcher is attached), ensuring window.__rokt_li_guid__ is reliably available
  • 10% sampling rate to limit traffic volume
  • pageUrl is stripped of both query params and hash fragments to avoid leaking sensitive state
  • Gated to a single allowed hostname via djb2 hash check (no plaintext domain in source)

Changes

  • src/Rokt-Kit.js: Add createAutoRemovedIframe helper, sendAdBlockMeasurementSignals with host hash gating, djb2 hash function, call from initRoktLauncher, expose via testHelpers
  • test/src/tests.js: 10 new tests covering iframe creation, auto-removal, sampling, GUID gating, hostname gating, fragment stripping, and integration-level init behavior

Companion PR

ecommerce-api changes (new wsdkInitControlStart metric, isControl query param): https://github.com/ROKT/ecommerce-api/pull/2377

Test plan

  • All 120 tests pass (npm test with ChromeHeadless)
  • npm run lint passes clean
  • After deployment, query sdk.TimingEvents Kafka topic for wsdkInitStart vs wsdkInitControlStart event counts
  • Verify formula: ad_block_rate = 1 - (wsdkInitStart_count / wsdkInitControlStart_count)

@mattbodle mattbodle force-pushed the feat/adblock-measurement-v2 branch from e82073c to 653332d Compare March 11, 2026 19:18
Fire two hidden iframes from the mParticle kit during launcher
initialization to compare signal counts between the existing
(potentially blocked) domain and a control domain (apps.roktecommerce.com).

- Add createAutoRemovedIframe helper and sendAdBlockMeasurementSignals
- Call from initRoktLauncher after GUID is reliably available
- 10% sampling rate, strips query/hash from pageUrl
- 9 new tests covering iframe creation, sampling, GUID gating, and integration

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mattbodle mattbodle force-pushed the feat/adblock-measurement-v2 branch from 653332d to 4d6c493 Compare March 11, 2026 19:25
@mattbodle mattbodle changed the base branch from main to development March 11, 2026 19:43
@mattbodle mattbodle merged commit 83bdc6d into development Mar 12, 2026
3 of 4 checks passed
@mattbodle mattbodle deleted the feat/adblock-measurement-v2 branch March 12, 2026 13:58
github-actions bot pushed a commit that referenced this pull request Mar 12, 2026
# [1.17.0](v1.16.0...v1.17.0) (2026-03-12)

### Features

* Add Event Stream function ([#64](#64)) ([1fea071](1fea071))
* Improve observability through additional init signals ([#61](#61)) ([83bdc6d](83bdc6d))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants