Part II β The Shield Β· Lesson 3.8
Compliance & Regulation
In one lineConsent gates data collection, and the frontend is where that gate is actually built.
Where you've seen itThe cookie banner. Done properly, no analytics script exists on the page until consent is given β the banner isn't a notice, it's a switch.
Diagram
CONSENT GATE β the script must not load before the click
page load
β
βΌ
ββββββββββββββββββ no consent stored
β essential only β βββββββββββββββββββββββΊ show banner
β (session, CSRF)β β
ββββββββββββββββββ βββββββββββ΄ββββββββββ
β Accept Reject
β β β
β βΌ βΌ
β inject analytics nothing loads
β + marketing tags (and stays that way)
βΌ
app renders either way β the product must work without consentWHAT COUNTS AS PERSONAL DATA β wider than most engineers assume
obvious name Β· email Β· phone Β· address Β· payment
also IP address Β· device id Β· cookie id Β· precise location
also behavioural profile built from clicks
special health Β· biometrics Β· religion Β· sexuality (stricter rules)THE FRONTEND'S FOUR OBLIGATIONS
1. Collect consent granular, opt-IN, as easy to refuse as accept
2. Honour it no tag fires before the switch flips
3. Show it privacy policy, what's collected, why
4. Enable rights export my data Β· delete my accountHow it works
- Classify what you collect before writing UI β you cannot gate what you haven't inventoried.
- Load nothing non-essential on first paint. Third-party tags are injected after consent, not disabled by a flag.
- Store the consent decision with a version and timestamp; re-ask when the policy changes.
- Make refusal one click. "Accept all" with a buried "Manage preferences" is the classic violation.
- Build the rights flows β data export and account deletion are product features, not support tickets.
Trade-offs
| Regulation | Frontend impact |
|---|---|
| GDPR (EU) | Opt-in consent, right to export and erase |
| CCPA (California) | "Do Not Sell My Info" link, opt-out model |
| DPDP (India) | Notice + consent, purpose limitation |
| WCAG / accessibility law | The banner itself must be keyboard-usable |
Data residency: some regimes require data to stay in-region, which changes which API origin the frontend calls β a routing decision, not just a legal one.
Interview angle
"Where does compliance touch frontend architecture?"
- Third-party scripts become conditionally loaded modules, so your tag manager and CSP
connect-srcmust both be consent-aware. - Analytics must degrade gracefully β the product works fully for users who refuse.
- PII must be scrubbed before it reaches logging and error reporting (see Chapter 7).
Recap
- Consent is a load-time gate, not a runtime flag.
- IP addresses, device ids, and cookie ids are personal data.
- Export and delete are features you build, and refusal must be as easy as acceptance.