Cookies loading before consent: how to fix it
If your site sets analytics or advertising cookies the moment a page opens, your cookie banner is not doing its job. The fix is to hold those scripts back until the visitor says yes, then confirm it in your browser.
Many sites show a cookie banner but still drop tracking cookies the instant a page loads. The banner appears, the visitor has not clicked anything, and Google Analytics, a Meta pixel or an advertising tag is already running. This page explains what that means, how to check your own site for free, and how to fix it.
What the problem looks like
A visitor lands on your site. Before they touch the banner, their browser already holds cookies with names like _ga, _gid, _fbp or _gcl_au. The banner may look fine and the Accept button may work, but it only records a choice. It does not stop anything from running first.
The usual cause is that the tracking code is added in a way the banner cannot control. It might be pasted straight into the theme, added by a separate plugin or app, or fired by a tag manager with no consent rule attached.
Why it matters
In the EU and UK, rules based on GDPR and the ePrivacy Directive (PECR in the UK) generally require consent before you store non-essential cookies, such as analytics and advertising ones. A banner that appears after the cookies are set does not meet that. This is not legal advice, so ask a qualified person if you need certainty for your situation.
- Trust: visitors who decline cookies expect them not to be set. If they check, a mismatch looks careless.
- Complaints and fines: regulators and privacy complainants often test sites in exactly the way described below.
- Sales: advertising platforms and some partners increasingly expect clean consent signals. Bad signals can mean unreliable data.
- Security and hygiene: every third-party script that loads early is code from another company running on your pages. Fewer early scripts is a safer site.
Not all cookies need consent. Strictly necessary ones, such as a shopping cart, a login session, a security token or the cookie that remembers the visitor's consent choice, are normally fine to set straight away.
How to check your site for free
Use a private window so you start with no stored choice.
- Open a new private or incognito window in Chrome, Edge or Firefox.
- Open your site's home page. Do not click anything on the banner.
- Open developer tools (F12, or right click and choose Inspect).
- In Chrome or Edge, go to the
Applicationtab, thenCookies, and select your domain. In Firefox, use theStoragetab. - Read the list. Note any cookie you do not recognise as essential.
- Also look at the
Networktab and reload. Requests to domains likegoogle-analytics.com,googletagmanager.com,facebook.comordoubleclick.netbefore any consent are a warning sign.
Also look at cookies set by other domains, not only your own. If you are unsure what a cookie does, search its name; most common ones are well documented.
SiteMonday's week 27 check looks at GDPR and cookie consent as part of the weekly service, with a written report and a ranked fix list. Details are on the week 27 page. The browser check above is free and shows you the same basic picture.
How to fix it in general
The principle is the same everywhere: tracking scripts must not run until consent is given for their category.
- List every tracker. Include analytics, advertising pixels, heatmaps, chat widgets, embedded videos and maps. Embedded YouTube and some maps can set cookies too.
- Use a consent tool that blocks, not just informs. Well-known options include Cookiebot, CookieYes, Complianz, iubenda and OneTrust. Look for a setting called something like automatic blocking, prior consent or script blocking.
- Assign each script a category. Typical categories are necessary, analytics, marketing and preferences. Analytics code should wait for the analytics choice, pixels for marketing.
- Remove hardcoded copies. If the tracking code is pasted in your theme and also managed by a plugin, delete the pasted copy after backing up your theme and confirming the plugin really loads the same tracker. Otherwise it keeps firing regardless.
- Set defaults to denied. Nothing non-essential should be on until the visitor opts in.
- Make rejecting as easy as accepting. A Reject button of equal prominence is widely expected.
If you use Google Tag Manager, the key idea is that tags should fire only when the matching consent type is granted. GTM has consent settings on each tag and a consent overview screen. Google's Consent Mode can also tell Google tags to respect the visitor's choice, but how it behaves depends on whether you use the basic or advanced setup, so read your consent tool's instructions. See the Google Tag Manager guide for detail.
Advertising pixels deserve special care. The Facebook pixel without consent page covers that case.
Common platforms
Menu names change between versions and themes, so treat these as pointers.
- WordPress: the problem often comes from a theme setting, a header and footer scripts plugin, or an analytics plugin running alongside the consent plugin. Check each, and see the WordPress guide.
- Shopify: look under
SettingsandCustomer privacyfor the built-in banner and regions. Apps and pixels added throughCustomer eventsor the theme code may need to be tied to consent. - Wix: the cookie banner is usually under
Settings, and marketing tools added through the dashboard can be assigned a cookie category. Custom code you add yourself needs a category too. - Squarespace: look for cookie banner options in
Settings, and checkCode Injectionfor pasted trackers that bypass the banner. - Webflow: custom code in
Project settingsor on individual pages runs regardless unless your consent tool controls it. - Next.js and custom sites: your developer needs to load tracking scripts only after the consent callback fires, not in the page head by default.
How to confirm the fix worked
Repeat the check from earlier in a fresh private window.
- Load the site and do not touch the banner. Only essential cookies should appear.
- Reload and confirm the tracking requests in the
Networktab are gone. - Click Reject. Cookies and requests should stay clear of trackers.
- Open a new private window, click Accept, and confirm the analytics and marketing cookies now appear.
- Try a second page and a mobile browser, since some scripts only load on certain templates.
If cookies from a previous visit remain, clear your browser cookies first. Old cookies can make a fixed site look broken.
How to stop it coming back
The problem usually returns when someone adds a new tool. A marketer pastes in a new pixel, a plugin update adds its own tracking, or a theme change removes the consent script.
- Keep one place where tracking is added, ideally your tag manager or consent tool, and tell your team to use it.
- Repeat the private window check after every new plugin, app, theme change or campaign tag.
- Keep your cookie list and policy up to date. If the banner works but nothing explains the cookies, see cookie banner not showing and no cookie policy page for related gaps.
- Because SiteMonday's weeks follow the calendar, the week 27 check comes round again each year, which gives you a regular reminder to test.
SiteMonday finds and explains problems. Making the changes is up to you or your developer.
Step by step for your platform
- Cookies set before consent is given on WordPress
- Cookies set before consent is given on Shopify
- Cookies set before consent is given on Google Tag Manager
- Cookies set before consent is given on Wix
- Cookies set before consent is given on Squarespace
- Cookies set before consent is given on Webflow
- Cookies set before consent is given on Next.js
Questions
Do all cookies need consent?
No. Strictly necessary cookies, such as those for a shopping cart, login, security or remembering the consent choice, normally do not need consent. Analytics and advertising cookies generally do.
Is a cookie banner enough on its own?
No. A banner only helps if the scripts it covers are blocked until the visitor agrees. If trackers load first, the banner is just a notice.
Why do I still see cookies after I click Reject?
Some scripts may be hardcoded in your theme or added by a plugin outside the consent tool. Remove duplicates and assign every script a category, then test in a fresh private window.
Does Google Analytics need consent?
Under GDPR and ePrivacy rules, it generally does when it sets cookies on visitors in the EU or UK. Consent Mode can help Google tags respect choices, but check how your setup behaves.
Can I fix this without a developer?
Often yes on WordPress, Shopify, Wix or Squarespace, using a consent tool's blocking feature and removing pasted tracking code. Custom sites or tricky tag setups may need a developer.
How often should I check for this?
Check after any change that adds a tool, such as a new plugin, pixel, theme or campaign tag. A quick private window check takes a few minutes.