Skip to content

feat: add X Ads download conversion tracker to DownloadAdDialog#748

Merged
nahcnuj merged 2 commits into
sourcefrom
add-x-ads-download-tracker
Jul 5, 2026
Merged

feat: add X Ads download conversion tracker to DownloadAdDialog#748
nahcnuj merged 2 commits into
sourcefrom
add-x-ads-download-tracker

Conversation

@nahcnuj

@nahcnuj nahcnuj commented Jul 5, 2026

Copy link
Copy Markdown
Owner

��## Summary
Add X (Twitter) Ads conversion tracking specifically for downloads.

  • Fires the provided X conversion event on download button clicks inside DownloadAdDialog.
  • The base pixel script is only included on pages that contain download content (downloadAdPopup: true via the download link plugin).
  • Non-download pages (index, regular essays, diary posts, etc.) receive no X tracker code.

Changes

  • app/components/DownloadAdDialog.tsx: Extended setupDownloadAdPopup with optional xPixelFn.
  • app/client.ts: Added xPixelFn (prod: calls twq, dev: logs; includes safe queuing stub).
  • app/components/RootLayout.tsx: Added conditional X base code snippet (only PROD && downloadAdPopup).
  • app/components/DownloadAdDialog.test.ts: Added tests for the new X pixel firing path (both alone and together with GA).

Verification

  • All unit tests pass (144/144).
  • Full production build succeeds.
  • Confirmed via built HTML:
    • Download pages (/essays/download-link*, /works/download-link-test) contain the X base code.
    • All other pages have zero occurrences of twq, ov0j6, or "X conversion tracking".

This is a non-visual / analytics-only change (no screenshots needed per AGENTS.md).

Code installed

<!-- X conversion tracking event code -->
<script type="text/javascript">
  // Insert X Event ID
  twq('event', 'tw-ov0j6-ov0j9', {});
</script>
<!-- End X conversion tracking event code -->

(The base code is loaded once per qualifying page; the event is fired from the JS download handler.)

@nahcnuj nahcnuj enabled auto-merge (squash) July 5, 2026 03:27
nahcnuj added 2 commits July 5, 2026 12:28
- Add X pixel event firing (twq('event', 'tw-ov0j6-ov0j9', {})) on download clicks
- Inject X conversion tracking base code only for pages with download content (conditional on downloadAdPopup frontmatter, prod only)
- Mirror gtagFn pattern with xPixelFn (dev logging + safe prod stub/queue)
- Update tests to cover new X pixel path
- Verified: non-download pages (index, most essays/diary) have no X tracker code; only download-link pages do
- Non-visual change; no screenshots required per AGENTS.md
@nahcnuj nahcnuj force-pushed the add-x-ads-download-tracker branch from 4d0e9c4 to 5c60800 Compare July 5, 2026 03:28
@nahcnuj nahcnuj merged commit 539e5ee into source Jul 5, 2026
10 checks passed
@nahcnuj nahcnuj deleted the add-x-ads-download-tracker branch July 5, 2026 03:29
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.

1 participant