Data flow
A high-level view of what data the test collects, where it goes, and what stays in the user’s browser.
Overview
The hearing test supports two data-capture flows. The primary flow is the PDF flow, where a full PDF report is generated at the end and user data is pushed to the CRM via webhook. The secondary flow is a lighter Klaviyo-only lead-capture variant used when a full report is not required.
- Primary — PDF flow: profile + questionnaire saved to the app’s own database, a multi-page PDF report is generated client-side, uploaded to the app’s storage, and report metadata is pushed to the CRM webhook for email automation.
- Secondary — Klaviyo lead capture: first name, email, and consent only, submitted via a Klaviyo-hosted form and stored in Klaviyo. No PDF, no own-database storage.
(any origin)"] U["User's browser"] A["Hearing test app
(iframe)"] subgraph primary ["Primary — PDF flow"] DB["App database
(profile + answers)"] PDFGEN["PDF generated client-side
(jsPDF + html2canvas)"] S["App storage
(/uploads)"] W["CRM webhook
(email automation)"] DL["PDF downloaded
to user"] end subgraph secondary ["Secondary — Klaviyo lead capture"] K["Klaviyo
(lead storage)"] end P -- "embeds iframe" --> A U -- "interacts with" --> A A ==> |"POST /api/save-profile"| DB A ==> |"render audiogram
& interpretation"| PDFGEN PDFGEN ==> |"POST /api/upload-pdf"| S S ==> |"report link + user data"| W PDFGEN ==> DL A -. "alternative lead form
(name, email, consent)" .-> K classDef ext fill:#ecfeff,stroke:#06b6d4,color:#0f172a; classDef app fill:#eef2ff,stroke:#6366f1,color:#0f172a; classDef own fill:#dcfce7,stroke:#16a34a,color:#0f172a; classDef client fill:#fef9c3,stroke:#ca8a04,color:#0f172a; class K,W ext class A app class DB,S own class PDFGEN,DL client
Solid arrows show the primary PDF flow; the dotted arrow is the secondary Klaviyo-only alternative. Green = app-owned storage, yellow = client-side only, blue = third party.
Primary flow — PDF flow
- User fills the profile form (name, surname, email, phone, province) and a short questionnaire (phone use, hearing problem, hearing-aid use, terms).
-
Profile + answers are posted to
/api/save-profileand stored in the app’s database (one row per user + one row per answer). - User completes the tone test; thresholds are captured in-browser.
-
On the results page, the user clicks Download PDF. The audiogram
and interpretation panels are rasterised with
html2canvasand composed into a three-page PDF withjsPDF(profile + questionnaire, audiogram, interpretation). -
The PDF is uploaded to the app’s own storage via
/api/upload-pdf. The public URL is returned to the browser and cached inlocalStoragefor re-downloads. -
The browser POSTs the formatted user data plus
report_linkto the CRM webhook, which fans out to the email automation. - The browser then triggers a download of the PDF to the user’s device.
Secondary flow — Klaviyo lead capture
When the deployment does not need a full PDF report (for example a pure lead-gen
landing page), the profile step is replaced with a Klaviyo-hosted form. The
form’s submission is handled entirely by Klaviyo: name, email and consent are
stored as a lead, and the user’s first name is mirrored to
localStorage so the rest of the test can greet them by name. Nothing
is saved to the app’s own database and no PDF is produced in this flow.
What is collected
| Flow | Data | Where it goes | Why |
|---|---|---|---|
| Primary | Name, surname, email, phone, province, questionnaire answers, terms | App database (/api/save-profile) |
Lead record & PDF personalisation |
| Primary | Tone thresholds per ear / frequency | Browser memory → rendered into PDF | Audiogram & interpretation in the report |
| Primary | Generated PDF file | App storage (/public/uploads), public URL |
Re-downloadable report + attached to CRM record |
| Primary | Formatted user data + report_link |
CRM webhook → email automation | Follow-up flow for the lead |
| Secondary | First name, email, consent | Klaviyo (via embedded form) | Lightweight lead capture & email list |
| Both | First name | Browser localStorage |
Personalising the test and results screen |
Third parties
- CRM webhook (primary flow) — receives the webhook payload with user info and PDF report link, then fans out to the configured email automation scenario.
-
Klaviyo (secondary flow) — hosts the alternative
lead-capture form and stores the lead. Loaded via the Klaviyo onsite script
(
static.klaviyo.com/onsite/js/klaviyo.js).