All guides

Privacy

Cookie consent for SaaS: what to block until the visitor says yes

Which cookies need consent, how to load Google Analytics and ad pixels only after a yes, why Reject must be as easy as Accept, and how to test it.

ScanMySaaS Editorial Team3 min readUpdated November 12, 2026

Most SaaS cookie banners fail the same way: the banner appears, and Google Analytics, the Meta Pixel and Hotjar have already set their cookies behind it. The banner asks a question the page has stopped waiting for.

This guide covers EU and UK consent rules first, because they are the strictest, then what changes for US visitors. It is practical guidance, not legal advice.

Check your site for these issues with the free website vulnerability scanner.Scan now →

Which cookies need consent

Article 5(3) of the EU ePrivacy Directive requires consent before a site stores or reads anything on a visitor's device, unless it is strictly necessary for a service the visitor asked for. The UK has the same rule in PECR. GDPR then defines what valid consent is: freely given, specific, informed and an active choice.

Strictly necessary covers the login session, a CSRF token, a load balancer cookie and the cookie that stores the consent choice itself. Analytics, advertising pixels and session replay are not necessary for the service, so they wait. France's CNIL exempts some audience-measurement setups that meet strict conditions, but a default Google Analytics install is not one of them.

  • No consent needed: session, CSRF, load balancing, language preference, the consent record.
  • Consent needed: Google Analytics, Google Ads, Meta Pixel, LinkedIn, TikTok, Hotjar, Microsoft Clarity, most product analytics that set identifiers.
  • Cookieless analytics is not automatically exempt: reading identifiers from the device can still fall under Article 5(3), and the data is still personal data under GDPR.

Load tags only after a yes

The fix is about load order, not the banner design. Nothing that sets a tracking cookie may run before the visitor accepts, and it must check the stored choice again on every page load.

For Google tags, set consent mode to denied before gtag or Google Tag Manager loads, then update it when the visitor accepts. Google then sends cookieless pings until consent is given. For every other tag, let your consent tool inject the script, or ship it as type="text/plain" with the tool's category attribute so the browser does not run it.

  • gtag('consent', 'default', { analytics_storage: 'denied', ad_storage: 'denied', ad_user_data: 'denied', ad_personalization: 'denied' });
  • On accept: gtag('consent', 'update', { analytics_storage: 'granted', ad_storage: 'granted', ad_user_data: 'granted', ad_personalization: 'granted' });
  • In Next.js, render analytics scripts only from a client component that reads the stored consent, never unconditionally in app/layout.tsx.

Make Reject as easy as Accept

A banner with "Accept all" and a small "Settings" link is the most common design and the one regulators fine. In January 2022 the CNIL fined Google 150 million euros and Facebook 60 million euros because refusing cookies took more clicks than accepting them. Put "Reject all" on the first layer, with the same size and weight as "Accept all".

Pre-ticked boxes do not count either. In Planet49 (C-673/17), the Court of Justice of the EU held that a pre-checked checkbox is not valid consent. The same applies to a marketing checkbox on a sign-up form.

US visitors: opt-out instead of opt-in

California's CCPA, as amended by the CPRA, works the other way round. A covered business may set advertising cookies first, but if sharing data with ad platforms counts as selling or sharing, it must offer a "Do Not Sell or Share My Personal Information" link and treat the Global Privacy Control browser signal as an opt-out. The law applies only above its revenue or data thresholds, so check whether you are covered before building it.

Test it yourself in five minutes

Use a private window so no earlier choice is stored. If your banner only shows to EU visitors, test through an EU connection.

  • Open the site and do not click anything. In DevTools > Application > Cookies, look for _ga, _gcl_au, _fbp, _hj or _clck. Any of them means tags run before consent.
  • Click Reject, reload the page, and check again. Delete the old cookies first so you see only what comes back.
  • Accept, reload, and confirm analytics now works. A setup that never loads after consent loses data for nothing.
  • A ScanMySaaS website scan lists the trackers it finds in your HTML on every plan. On Starter and Pro it also loads the page in a real browser and runs the first two tests automatically.

Related:GDPR cookie checkerPrivacy policy checklist

Sources

Check your production site

See which of these issues are visible now.

ScanMySaaS checks the public surface and keeps the affected URL with every finding. Verify results before changing production.

Run a free scan