Skip to content

feat(pixel): auto-capture form submissions and outbound link clicks#2833

Merged
bkbooth merged 2 commits into
mainfrom
benbooth/sdk-52-pixel-auto-capture-form-submissions-and-outbound-link-clicks
Apr 8, 2026
Merged

feat(pixel): auto-capture form submissions and outbound link clicks#2833
bkbooth merged 2 commits into
mainfrom
benbooth/sdk-52-pixel-auto-capture-form-submissions-and-outbound-link-clicks

Conversation

@bkbooth
Copy link
Copy Markdown
Contributor

@bkbooth bkbooth commented Apr 8, 2026

Summary

Implements SDK-52: passive event capture for form submissions and outbound link clicks — the two most valuable conversion signals the pixel can collect without any studio instrumentation.

  • Form submissions: Document-level submit listener captures formAction, formId, formName, fieldNames. At full consent, SHA-256 hashes email values client-side before enqueuing (raw email never enters the queue). At anonymous, captures form metadata only. Silent at none.
  • Outbound link clicks: Document-level click listener targets <a> tags where hostname differs from window.location.hostname. Captures linkUrl, linkText (truncated to 256 chars), elementId, outbound: true. Silent at none.
  • Configurable: autocapture: { forms: true, clicks: true } in init options (both default to true)
  • Bundle impact: ~0.5KB gzipped added (total pixel bundle: 4.1KB gzipped, well under 10KB budget)

Files changed

File Change
autocapture.ts New — form submission + outbound click listeners with SHA-256 email hashing
autocapture.test.ts New — 30 tests covering consent levels, config toggles, email hashing, teardown
pixel.ts Wire autocapture into init/destroy, add track() helper, autocapture option
pixel.test.ts Add integration tests for autocapture wiring
index.ts Export AutocaptureOptions type

Test plan

  • Form submission fires at anonymous (no email hash), fires with SHA-256 email hash at full, silent at none
  • Click capture fires for outbound links, silent for internal links, silent at none
  • Config: autocapture: { forms: false } disables form listener, { clicks: false } disables click listener
  • Email hashing: consistent deterministic SHA-256 output, normalises case and whitespace before hashing
  • Child element clicks resolve to nearest <a> ancestor
  • Teardown removes all listeners
  • Pixel integration: autocapture wired on init, torn down on destroy, consent callback reflects live state
  • Lint passes with zero warnings
  • Bundle size verified: 4.1KB gzipped total

🤖 Generated with Claude Code

…clicks

Add passive event capture for form submissions and outbound link clicks,
firing as TrackMessage events with surface: 'pixel'. Both use single
document-level listeners (event delegation) and respect consent state.

Form submissions capture formAction, formId, formName, fieldNames, and
at full consent, SHA-256 hash email values client-side before enqueuing.
Outbound link clicks capture linkUrl, linkText, elementId, outbound flag.
Both configurable via autocapture init option.

Bundle impact: ~0.5KB gzipped (total pixel bundle: 4.1KB gzipped).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bkbooth bkbooth requested a review from a team as a code owner April 8, 2026 03:00
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 8, 2026

View your CI Pipeline Execution ↗ for commit b472566

Command Status Duration Result
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-08 04:19:36 UTC

@bkbooth bkbooth changed the title feat(pixel): auto-capture form submissions and outbound link clicks SDK-52: auto-capture form submissions and outbound link clicks Apr 8, 2026
@bkbooth bkbooth changed the title SDK-52: auto-capture form submissions and outbound link clicks feat(pixel): auto-capture form submissions and outbound link clicks Apr 8, 2026
Comment thread packages/audience/pixel/src/autocapture.ts
When crypto.subtle is unavailable (HTTP pages, some privacy browsers,
Safari <15 non-secure contexts), enqueue form_submitted without emailHash
rather than silently losing the event entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bkbooth bkbooth added this pull request to the merge queue Apr 8, 2026
Merged via the queue into main with commit 9358aeb Apr 8, 2026
10 of 11 checks passed
@bkbooth bkbooth deleted the benbooth/sdk-52-pixel-auto-capture-form-submissions-and-outbound-link-clicks branch April 8, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants