Skip to content

feat(ads): keep every ad click a contact comes from - #1558

Merged
viethung0o0 merged 1 commit into
mainfrom
feat/contact-ad-referral-history
Oct 28, 2026
Merged

viethung0o0 merged 1 commit into
mainfrom
feat/contact-ad-referral-history

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

  • A contact used to keep only the last ad it came from. Every ad click is now stored, so a contact that clicked ad 1 and later ad 2 keeps both.
  • Contacts can be listed and filtered by any ad they clicked, and conversions point to the click they came from. Attribution itself is unchanged.

Changes

  • New ContactReferralEvent table with one row per click (WhatsApp, Messenger, Instagram and Zalo Google clicks). Retries do not create duplicates and organic referrals are skipped.
  • Writing the history never fails the message or action that carries the referral.
  • System fields {{ad_ids}} and {{ad_id}} (first ad).
  • New "Clicked ad" contact filter, built on the contact activity store, with an ad picker.
  • Public API: contacts.listAdReferrals, ads.listReferralAds and ads.referralStats. CLI docs updated.
  • "Ads history" section in the contact panel and a contacts-per-ad table on the Ads dashboard.
  • Conversions store a link to the click they were credited to.
  • Migrations are split so large tables are not locked for long. Docs updated.

Test plan

  • Unit and component tests for the writer, history, filter, reports, APIs and UI
  • Affected workspace suites, type checks, lint and i18n check pass
  • Checked the new queries, filter counts and reports on a dev database with sample clicks
  • Apply migrations (pnpm --filter @chatbotx.io/database db:migrate) before deploying the app
  • Check the Ads history section and the Ads dashboard table in the browser

@github-actions github-actions Bot added the feature New feature or request label Oct 26, 2026
@viethung0o0
viethung0o0 force-pushed the feat/contact-ad-referral-history branch 2 times, most recently from 1952127 to c2ba52c Compare October 28, 2026 03:56
Contacts used to keep only their latest ad. Every click is now stored, so contacts can be listed and filtered by any ad they clicked, and conversions point to the click they came from.

- add an append-only ContactReferralEvent log written from the one place that updates the referral snapshot
- show the ad history on the contact profile and add it to the public API
- add the Clicked ad contact filter and the ad_ids and ad_id system fields
- add per-ad contacts, first touch and credited conversions to the Ads dashboard
@viethung0o0
viethung0o0 force-pushed the feat/contact-ad-referral-history branch from c2ba52c to 25e3349 Compare October 28, 2026 08:17
@viethung0o0
viethung0o0 marked this pull request as ready for review October 28, 2026 08:29
@viethung0o0
viethung0o0 merged commit f8dacb8 into main Oct 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants