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.
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
- Load the page. Do not touch the banner.
- In the cookie list, look for analytics and advertising cookies. Common names:
_ga,_gid,_fbp,_gcl_au,_hjSession*,_uetsid. - 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
- In a new private window, load the page and click "Reject all" (or the equivalent).
- Browse to two or three more pages.
- 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
| Symptom | Usual cause | Fix |
|---|---|---|
| Analytics cookie on first load | Tag fires on "All pages" instead of on consent | Trigger 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 manager | Move it into the tag manager behind consent, or wrap it in a consent check |
| Trackers only on some pages | Landing page builder or embedded widget with its own tags | Audit third-party embeds; load them only after consent |
| Tags fire on second page | Choice saved, but the trigger reads it too early | Wait 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.