How to check if your website sets cookies before consent

Step-by-step: test whether your site sets analytics or advertising cookies before a visitor agrees, what GDPR and the ePrivacy rules expect, and how to fix it.

Updated · 9 min read

This guide explains how to test what your website does. It is not legal advice; ask your legal team what your policy needs to say.

The rule in one sentence

Under the EU ePrivacy rules and GDPR, and the UK equivalents, cookies and similar trackers that are not strictly necessary (analytics, advertising, social pixels, session replay) may only be set after the visitor has agreed, and must not be set when they refuse. Refusing should be as easy as accepting.

The most common failure is not a missing banner. It is a banner that looks right while tags fire anyway.

Before you start

  • Use a fresh private window for every test, so earlier choices are not remembered.
  • Open developer tools before loading the page: the Application (Chrome) or Storage (Firefox) tab for cookies, and the Network tab with "Preserve log" on.
  • Test more than the home page. Landing pages built in other tools often carry their own tags.

Test 1: the visitor who ignores the banner

  1. Load the page. Do not touch the banner.
  2. In the cookie list, look for analytics and advertising cookies. Common names: _ga, _gid, _fbp, _gcl_au, _hjSession*, _uetsid.
  3. In the Network tab, filter for known tracker hosts: google-analytics.com, googletagmanager.com/collect, facebook.com/tr, doubleclick.net, bat.bing.com, hotjar.com.

Pass: only strictly necessary cookies (session, load balancer, the consent choice itself) and no tracker requests carrying identifiers.

Test 2: the visitor who rejects

  1. In a new private window, load the page and click "Reject all" (or the equivalent).
  2. Browse to two or three more pages.
  3. Repeat the cookie and network checks.

Pass: nothing new appears after refusing. Watch for tags that fire on the next page view, a frequent bug in tag manager triggers.

Test 3: the visitor who accepts

Accept all and confirm your tags now work. This proves your consent setup is not simply blocking everything, and gives you a reference list of what your site sets with consent, which is what your cookie policy should declare.

Also open the preferences panel, allow only one category (for example analytics) and check that advertising cookies stay off.

Test 4: Global Privacy Control

Global Privacy Control (GPC) is a browser signal meaning "do not sell or share my data". Several US state privacy laws require businesses to honour it. Browsers such as Firefox and Brave can send it, as can privacy extensions. With GPC on, check that advertising and sharing tags stay off. You can confirm the signal is sent by running navigator.globalPrivacyControl in the console; it returns true.

Cookie hygiene

While you have the cookie list open, check:

  • Every cookie is declared in your cookie policy, with its purpose and lifetime.
  • Lifetimes are reasonable. Cookies set to expire years from now are hard to justify.
  • Secure is set on every cookie on an HTTPS site, and always when SameSite=None.
  • HttpOnly is set on session cookies, so scripts cannot read them.

Common causes and fixes

SymptomUsual causeFix
Analytics cookie on first loadTag fires on "All pages" instead of on consentTrigger tags from the consent platform's event, or use consent mode
Pixel fires after "Reject all"Tag hard-coded in the page template, outside the tag managerMove it into the tag manager behind consent, or wrap it in a consent check
Trackers only on some pagesLanding page builder or embedded widget with its own tagsAudit third-party embeds; load them only after consent
Tags fire on second pageChoice saved, but the trigger reads it too earlyWait for the consent platform's ready event before evaluating

Run these tests on every page, every day. SonarKite's cookie consent scanner visits your site as a visitor who ignores, accepts, rejects, sends GPC and uses the preferences panel, and keeps a screenshot and request log of each as evidence.

Or let SonarKite run these checks for you.

Every check in this guide runs on its own, on every page, every day. Free for 30 days.