Skip to content

docs: send primary conversion events to the first-party conversion worker#8752

Open
pubkey wants to merge 1 commit into
masterfrom
claude/use-conversion-worker
Open

docs: send primary conversion events to the first-party conversion worker#8752
pubkey wants to merge 1 commit into
masterfrom
claude/use-conversion-worker

Conversation

@pubkey

@pubkey pubkey commented Jul 7, 2026

Copy link
Copy Markdown
Owner

This PR contains:

  • SOMETHING ELSE (docs-site analytics: first-party conversion tracking for Google Ads)

Describe the problem you have without this PR

Roughly half of the developer audience blocks gtag/Google Analytics, so Google Ads conversion tracking silently loses those users, and there is no way to attribute conversions back to ad clicks (no click-id capture existed). This PR wires the docs site to the first-party rxdb-events Cloudflare worker:

  • Click-id capture: on page load, a gclid (or iOS wbraid/gbraid) URL parameter is validated and stored in localStorage for 90 days (the Google Ads click-through window).
  • Primary conversion events (dev_mode_tracking_iframe, console-log-click, premium_lead, request-demo-sub, copy_on_page, visit_x_urls) are additionally sent via sendBeacon to the worker when a click id is stored. The worker stores them and Google Ads pulls them daily as offline conversions, so ad blockers cannot prevent conversion measurement. The set is declared explicitly in GOOGLE_ADS_PRIMARY_EVENTS (mirroring the existing Reddit primary-event pattern).
  • GA4 Measurement Protocol fallback: only when gtag is blocked, a (self-minted or _ga-derived) client id is attached so the worker forwards the event to GA4 for counting. Users with working gtag never take this path, preventing double counting.
  • The hook runs inside triggerTrackingEvent() after the existing per-user frequency capping, so caps apply equally to all trackers.
  • Corrects the outdated comment on revisit_3_days: it must stay observation-only because it fires on the return visit itself (a second ad click would generate and get credited for its own conversion).

Tracking code never throws (all storage/beacon access is wrapped) and stays inert on localhost/dev since the worker only accepts the https://rxdb.info origin for browser requests.

Todos

  • Typings (plain TS in docs-src, esbuild-checked)
  • Tests (no test infrastructure for docs-src analytics; verified against the deployed worker's validation rules, 17 unit tests on the worker side)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EPJvU6oisC97X9uzc1qfGC


Generated by Claude Code

…rker

Captures the Google Ads click id (gclid/wbraid/gbraid) on landing and
stores it for 90 days. The six primary conversion events
(dev_mode_tracking_iframe, console-log-click, premium_lead,
request-demo-sub, copy_on_page, visit_x_urls) are additionally sent via
sendBeacon to the rxdb-events Cloudflare worker, which Google Ads pulls
as offline conversions so ad blockers cannot prevent conversion
tracking. When gtag is blocked, a client id is attached so the worker
forwards the event to the GA4 Measurement Protocol; users with working
gtag are excluded from that path to prevent double counting. Also
corrects the revisit_3_days comment (self-triggering conversions must
not be primary).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EPJvU6oisC97X9uzc1qfGC
@pubkey pubkey force-pushed the claude/use-conversion-worker branch from 4e774a4 to 0ee4dd5 Compare July 7, 2026 14:25
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