# QuitSure Discovery — Payment & Tracking Design (final)

Decided with the BE team. Discovery is a front-end funnel that ends at the direct premium
payment page (Razorpay). It creates no users, updates no shared tables, and sends no identity
to the payment page. Razorpay collects the email and matches the user by hashed email; the app
handles onboarding after payment based on `vOnboardComplete`.

---

## Two audiences, one link, one behaviour

The link tells us who they are by whether it carries `?u=<hashed-email>`:

| Audience | Link | In the funnel | At payment |
|---|---|---|---|
| Remarketing email / push | `.../discovery/?u=<hash>&utm_source=discovery-email` | Personalized (name, cigs/day, currency from `/api/me`). We record `iUserID` on the session row. | User types email on Razorpay, pays. Already exists + `vOnboardComplete=1`, so post-payment they land straight on the 6-day program. |
| Ads (cold or retargeted) | `.../discovery/?utm_source=facebook&utm_campaign=...` (no `u`) | Generic experience. No email asked. | User types email on Razorpay, pays. If new, app runs V3 onboarding after they download; then the program. |

No email gate, no user creation, no prefill. Discovery keeps only what it already has:
personalization for known users, clickstream (`tbl_DiscoveryClickstream`), and the session
summary (`tbl_DiscoveryOnboarding`).

## Why no in-funnel email capture (ads)

Considered capturing email in the ad funnel for a remarketing list, decided against it:
- Paid ad funnels should be frictionless; a field before the pay button costs conversions.
- Ad visitors are already retargetable via the platform pixel / custom audiences.
- Razorpay captures every payer's email anyway.
- Avoids storing plaintext PII in the main DB.

If pixel retargeting underperforms later, revisit and store leads in the secured DB (never the
main DB).

## Conversion tracking

- **Remarketing email / push:** per-user, via the `iUserID` we record on `tbl_DiscoveryOnboarding`:
  `tbl_DiscoveryOnboarding.iUserID JOIN tbl_UserPrograms WHERE bPreviouslySubscribed=1 AND dFirstSubDate >= session date` (all programs). Do **not** attribute via `tbl_UserSources` / link-source, because FB ad UTMs overwrite the source.
- **Ads:** measured by the ad-platform pixel firing Purchase on the Razorpay success page, same as the seminar funnel.

## What Discovery sends to the payment page

Only `program=3&link-source=discovery` (base64 in `qs`). Nothing else. The payment page needs
no change from us.
