Skip to content
Tutorials Center
My learning

Topics

Lesson 30 of 40 ยท Trust, Security and Compliance

GDPR, Consumer Law and Accessibility

A developer's overview of shop compliance: consent, data minimization, export and deletion, retention, cookies, withdrawal rights, price transparency, policies and accessibility. Not legal advice.

A shop is a business that collects names, addresses, payment details and buying habits, and sells to consumers who have legal protections. Laws differ by country and change over time, so no tutorial can tell you what your shop must do. This lesson is a developer's map, not legal advice. Its purpose is to help you recognize which features your code needs to support, so that when a lawyer or compliance person says "we must allow data export" or "show the lowest recent price", you know what that means in a database and a template.

Examples lean on the European Union and the United Kingdom, because their rules are the most detailed and apply to any shop that sells to people there, wherever the shop is based. Other regions have similar ideas under different names (California's CCPA/CPRA, Brazil's LGPD and others). Check with a professional for your markets before launch.

Personal data and why it matters

Personal data is anything that can identify a person directly or indirectly: name, email, address, phone, IP address, device id, order history. In a shop, almost everything attached to a customer is personal data. Privacy laws such as the EU's GDPR give people rights over it and give you duties. The ones that touch code most are:

  • Lawful basis. You need a valid reason for each use of data. Fulfilling an order is covered by the contract. Marketing emails and non-essential tracking usually need consent. Fraud prevention and keeping legally required records have their own bases.
  • Transparency. A privacy policy says what you collect, why, for how long, who receives it (payment provider, carrier, email service) and how to exercise rights.
  • Data minimization. Collect only what you need. Do you need a phone number to ship a T-shirt? Do you need a birth date? Every extra field is extra risk and extra duty.
  • Security. Protect what you hold (see Securing an Online Shop), and tell authorities and affected people if a breach happens, within the deadlines the law sets.

Consent must be freely given, specific, informed and unambiguous, and as easy to withdraw as to give. In practice:

  • A newsletter box must not be pre-ticked, and must not be bundled with accepting the terms of sale.
  • Record the evidence: who consented, when, to what wording, and from which page. A timestamped row in a consents table beats a boolean on the user.
  • Keep consent per purpose (marketing email, analytics, personalized ads), because people may accept one and refuse another.
  • Withdrawal must really work: unsubscribe links must stop the email, and the tracking must stop loading.

For cookies and similar technologies (local storage, tracking pixels), the common rule in Europe is that those that are strictly necessary to provide what the user asked for (keeping a cart, staying logged in, security) need no consent, while analytics and advertising ones do, before they run. Accept and Reject buttons should be equally easy to use. A "consent mode" that loads scripts first and asks afterward does not meet that rule. See how consent affects measurement in Analytics, Funnels and Metrics.

Do not bury marketing consent inside the checkout. Many places allow marketing to existing customers about similar products with an easy opt-out, but the exact rules vary, so ask.

Access, export and deletion

Privacy laws let people ask what you hold about them, receive a copy in a common machine-readable format, correct mistakes, and ask you to delete their data. You usually have about a month to respond. The engineering challenge is knowing where the data lives. Make a data map: which tables, caches, logs, search indexes, backups, email tools, analytics tools and third parties store personal data.

Then build two operations:

  1. Export: gather the customer's profile, addresses, orders and consents into one file (JSON works well).
  2. Erase or anonymize: delete what you may delete, and keep what the law requires you to keep.

Deletion is rarely all or nothing. Tax and accounting laws usually require you to keep invoices for years, so you cannot delete the order records. The usual approach is to remove or replace the identifying fields that you no longer need (name, email, phone, address) and keep the financial facts the law requires, possibly in a restricted archive. Marketing data, saved cards (at the payment provider), wish lists and reviews tied to the account can usually go. Third parties need to be told, too: your email service and analytics tools hold copies.

This is easier when personal data is kept apart from order facts. An order that references a customer row, plus a copy of the address as it was at purchase (the snapshot from The Order Lifecycle and State Machines), can be anonymized by overwriting those fields.

JS Export and anonymize a customer

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The order and its amounts survive for accounting, while the person is gone from every field. The city and country stay because they may still be needed for tax reports, a decision you should confirm with your accountant.

Retention

Keep data only as long as you have a reason, and write the periods down: for example carts and unconverted guest data for a few weeks, inactive marketing contacts for a couple of years, invoices for as long as local tax law requires. Then automate it: a scheduled job that deletes or anonymizes expired data, including logs and backups on a rotation. A retention policy that exists only in a document does not count. Remember that search indexes, analytics exports and data warehouses also copy data and need the same rules.

Consumer law in the shop

Distance-selling laws protect consumers who cannot see goods before buying. In the EU and UK, the ideas to know are:

flowchart LR
    A["Order placed"] --> B["Goods delivered"]
    B --> C["14-day withdrawal<br/>window starts"]
    C --> D["Customer tells you<br/>they withdraw"]
    D --> E["Return the goods<br/>(within 14 more days)"]
    D --> F["Refund due within 14 days<br/>of notice (may wait for goods)"]

The right to withdraw from a distance purchase is separate from your own returns policy.

  • Right of withdrawal. For most distance purchases, consumers may cancel within 14 days of receiving the goods without giving a reason. If you fail to tell them about this right properly, the period can be extended significantly. Some goods are excepted, such as custom-made items, sealed items opened for hygiene reasons, and digital content once delivery began with the customer's explicit agreement. Your stock-and-refund flow (Fulfillment, Returns and Refunds) needs to model this window.
  • Clear price information. Prices shown to consumers in the EU include taxes, and mandatory extra charges such as shipping should be shown before the order is placed (Sales Tax, VAT and GST). Drip pricing, where fees appear only at the last step, is restricted.
  • Discount claims. When you announce a price reduction, EU rules require showing the previous price, generally the lowest price in the prior 30 days. Store price history so you can prove it (Pricing Models).
  • "Order with obligation to pay." The final button must clearly say it commits the buyer to pay, for example "Place order and pay".
  • Confirmation and records. Send a confirmation of the contract on a durable medium (usually email), including the terms, as shown in Transactional Email and Customer Lifecycle.
  • Legal information. Show the seller's identity and address, contact details, delivery times, payment methods, the complaint process, and the legal guarantee period for faulty goods (at least two years for goods in the EU).
  • Reviews and urgency. Fake reviews and false scarcity ("only 2 left" when untrue) are unfair commercial practices. See Product Pages, Media and Content for displaying reviews.

Terms, refund and privacy policies

Provide, and link from the footer and checkout: terms and conditions, privacy policy, cookie policy, shipping policy, returns and refund policy. Version them. Store which version each customer accepted at order time with the order, so you can show what applied. Write in plain language, and make sure the shop behaves the way the policy says: a policy that promises refunds in 14 days is only true if your system can issue them in time. Do not copy another shop's policy blindly; the legal context may not match yours.

Accessibility

Online shops are covered by accessibility rules in many places: the European Accessibility Act applies to many consumer e-commerce services in the EU from mid-2025, and in the United States, accessibility claims against shops are frequently brought under the Americans with Disabilities Act. The technical benchmark most often used is WCAG (the Web Content Accessibility Guidelines), usually at level AA. Details and scope vary by country and business size, so confirm what applies to you.

For a shop, the checklist is mostly good engineering:

  • Use semantic HTML: real buttons, links, headings, labels and landmarks.
  • Make everything usable by keyboard, with a visible focus indicator, including menus, filters, galleries and the cart drawer.
  • Provide alternative text for product images and avoid text inside images.
  • Keep sufficient color contrast and do not rely on color alone (a red border on an invalid field also needs a message).
  • Associate form errors with fields, announce them to assistive technology, and keep checkout labels visible. See Checkout Flow and Conversion.
  • Make sure CAPTCHAs and 3-D Secure challenges have accessible alternatives.
  • Test with a screen reader and keyboard, not only with automated tools, which find only part of the problems.

Accessibility improves conversion too: more people can complete a purchase, and it overlaps with good SEO (SEO for Online Shops).

JS A withdrawal-deadline calculator

Press Run (or Ctrl + Enter) to see the console output here.

No output.

This is a simplification: real rules differ by country, by product type and for multi-part deliveries, so treat the calculator as an illustration of why the date must be stored, not as a legal tool.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A customer asks you to delete their account, but you must keep invoices for tax purposes. What is the usual approach?

    Rights and legal duties are balanced field by field. Anonymize what you may, keep what the law requires, and limit access to the kept records.
  2. 2. Which consent design meets the usual European standard?

    Consent has to be specific, unambiguous and provable, so it is separate per purpose, opt-in and recorded.
  3. 3. Why should a shop store the version of the terms each customer accepted?

    Terms change over time. Storing the accepted version with the order shows what the customer agreed to.
  4. 4. Which statement about the 14-day withdrawal period is closest to the EU rule for most distance purchases?

    The period normally begins at delivery. Not informing the buyer properly extends it. Exceptions exist, so confirm the rules for your products.

Summary

  • This lesson is a developer overview, not legal advice; confirm requirements for each market you sell to.
  • Collect the minimum personal data, know where it lives with a data map, and respect purposes and consent that is specific, optional and provable.
  • Build export and erase/anonymize operations, and automate retention.
  • Consumer law shapes the product: withdrawal windows, price transparency, honest discount claims, a clearly binding order button, legal information and records of accepted terms.
  • Accessibility (WCAG AA as the common target) is a legal and commercial need, and semantic HTML and keyboard support do most of the work.

Next, the architecture that lets a shop handle growth and peak traffic: Architecture, Scaling and Peak Traffic.