Fixing Tracking That Runs Before Consent
A site can have a perfect-looking cookie banner and still break the rules, because the tracking code loads before anyone presses a button. Analytics tags fire on page load, advertising pixels drop their cookies, and embedded videos and chat widgets phone home, all while the banner waits for an answer.
It happens when tags are pasted into theme files, added by plugins, or configured in Tag Manager without consent checks. This guide shows how to find every early request, make each one wait, and prove it. It is general guidance, not legal advice.
Why tracking leaks past the banner
PECR requires consent before you store information on a visitor's device or read information from it, unless an exemption applies. The rule is about what the code does, not what the banner looks like. If a tag sets a cookie, writes to local storage or reads a device identifier on page load, the consent question has already been answered for the visitor, whatever they click next.
The usual routes by which tracking escapes the banner are:
- Hard-coded snippets. An analytics or pixel snippet pasted into
header.php,theme.liquidor a static template runs before the consent tool has even loaded. - Plugins and apps with their own tracking. Many SEO, shop, form and marketing plugins include an "add your tracking ID" option that injects the tag directly.
- Tag Manager tags on All Pages. Tags set to fire on every page view with no consent condition fire immediately.
- The consent script loading too late. If the consent tool is deferred or placed at the bottom of the page, other scripts win the race.
- Third-party embeds. YouTube, Vimeo, Google Maps, social feeds, review widgets and chat tools set their own cookies and storage when the iframe loads.
- Cached pages. A page cache or CDN may store a version of the page rendered after someone accepted, and serve it to everyone.
The strictly necessary exemption, and the newer exemptions added to PECR by the Data (Use and Access) Act 2025 for some low-risk purposes, do not cover advertising or social media pixels. For analytics, check the ICO's current guidance on any exemption and its conditions before treating a tag as allowed to load early. This guide assumes any tracking that is not clearly exempt waits for consent.
Finding the leaks in your browser
You do not need special software to see tracking before consent. A browser shows you everything:
- Open a new private or incognito window, so there are no existing cookies or stored choices.
- Open the developer tools before loading the site. In the Network panel, tick Preserve log and clear the list.
- Load your home page and do not touch the banner.
- In the Network filter box, try the domains below one at a time. Any request listed is a leak.
- In the Application panel (Storage in Firefox), look at Cookies, Local storage and Session storage for your domain and third-party domains.
- Repeat on a product or article page, a page with an embedded video, and a page with a form, because different templates load different scripts.
| Filter for | Usually means | Typical cookie or storage |
|---|---|---|
google-analytics.com, /g/collect | Google Analytics 4 sending hits | _ga, _ga_XXXXXXX |
googletagmanager.com | Tag Manager or gtag.js loading (loading the library alone is not the problem; what it fires is) | None by itself |
doubleclick.net, googleadservices.com | Google Ads conversion or remarketing tags | _gcl_au, IDE |
facebook.com/tr, connect.facebook.net | Meta Pixel | _fbp |
clarity.ms, hotjar | Session recording and heatmaps | _clck,
_hj keys |
analytics.tiktok.com, px.ads.linkedin.com | TikTok or LinkedIn advertising pixels | _ttp, li_ cookies |
youtube.com, ytimg, vimeo | Video embeds loading on page load | Various cookies and local storage keys |
Google Consent Mode, explained plainly
Google's Consent Mode lets Google tags adjust their behaviour according to consent signals. Version
2 uses four main signals: ad_storage, analytics_storage, ad_user_data
and ad_personalization. Google requires advertisers who use its advertising features with
visitors in the UK and EEA to send these signals. Consent Mode does not show a banner and does not collect
consent; your consent tool does that and passes the result on.
The default state must be set before any Google tag runs. On a site without Tag Manager, that means
a small block at the very top of the <head>:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'functionality_storage': 'denied',
'personalization_storage': 'denied',
'security_storage': 'granted',
'wait_for_update': 500
});
</script>
<!-- consent tool script next, then gtag.js -->
When the visitor chooses, the consent tool calls an update, for example gtag('consent', 'update', {'analytics_storage': 'granted'}),
and the tags respond.
Basic and advanced implementations
Google describes two ways of using Consent Mode. In the basic approach, Google tags do not load at all until the visitor consents. In the advanced approach, the tags load straight away with consent denied and send cookieless pings that Google uses for modelling. Advanced mode does not set Google's cookies before consent, but it still sends requests from the visitor's browser to Google before they have chosen. If you want the cautious position under PECR and UK GDPR, the basic approach is the simpler one to defend. Whichever you choose, describe it in your cookie policy.
Making non-Google scripts wait
Consent Mode only controls Google's own tags. Everything else, from a Meta Pixel to a live chat widget, needs to be held back by your consent tool or tag manager. There are three common patterns:
1. Fire the tag from Tag Manager on a consent trigger
Remove the snippet from the site and recreate it as a tag in Tag Manager. Use your consent tool's template or built-in consent checks so the tag only fires once the matching category, such as marketing, is granted. Use the Consent Initialization trigger for the consent tool itself, so it runs before everything else.
2. Change the script type until consent
Many consent tools can activate scripts that are marked as inactive. The browser ignores a script whose type is not JavaScript, and the tool swaps it back after consent. The attribute names vary by tool, so check your tool's documentation; the pattern looks like this:
<!-- before: runs immediately -->
<script src="https://widget.example.com/chat.js"></script>
<!-- after: held until the "functional" category is accepted -->
<script type="text/plain" data-category="functional"
data-src="https://widget.example.com/chat.js"></script>
3. Click-to-load placeholders for embeds
For video, maps and social posts, show a still image or a simple box with a button such as "Load video
(YouTube will set cookies)". Only insert the iframe once the visitor clicks or has accepted the relevant
category. The privacy-enhanced youtube-nocookie.com address reduces what YouTube stores
before playback, but it still uses browser storage, so it is not a complete substitute for a consent
check.
Where early tags hide on each platform
| Platform | Places to look | What to do |
|---|---|---|
| WordPress | Theme header and footer files, "insert headers and footers" plugins, analytics options in SEO, shop and form plugins, page builder custom code boxes | Remove each copy and add the tag once through Tag Manager or the consent plugin's script manager. |
| WooCommerce | Marketing and product feed extensions that add pixels for ads platforms | Use the extension's consent integration if it has one, or turn its pixel off and fire the tag through Tag Manager. |
| Shopify | theme.liquid, app embeds, the older additional scripts box on the
checkout settings | Move pixels into customer events or apps that read Shopify's customer privacy settings. |
| Static and custom sites | Base templates, layout components, _document or
root layout files in frameworks | Load the consent tool first and wrap every third-party script in its blocking method. |
| Single-page apps | Route change listeners that send page views, analytics libraries imported in the bundle | Initialise analytics only after a consent callback, and check route-change events respect it. |
Also check the caching layer. After any change, purge the page cache and CDN, then confirm the first page view in a private window is served without tracking.
The fix, step by step
Step 1
Capture what loads before any choice
Open a private window, open the developer tools with Preserve log ticked, and load the home page without touching the banner. Filter the Network panel for analytics, advertising, recording and embed domains, and check the Application panel for cookies and local storage. Repeat on each main template, such as article, product, basket and contact pages. Write down every request and stored item that appeared before a choice, together with the page it came from.
Step 2
Trace each request back to where it was added
For each early request, click it in the Network panel and open the Initiator column or tab to see which script started it. Then search your theme files, plugin settings, app embeds and Tag Manager container for that tracking ID or domain. It is common to find the same tag in two places, for example a hard-coded snippet and a Tag Manager tag, so keep searching after the first match you find.
Step 3
Set consent defaults before any tag loads
Move the consent tool's script to the top of the <head>, or fire
it on Tag Manager's Consent Initialization trigger. If you use Google tags, set every Consent Mode signal
to denied by default, apart from security storage, before gtag.js or the Tag Manager container runs.
Decide between the basic and advanced Consent Mode approaches, record the reason for your choice, and
make sure the consent tool sends an update when the visitor chooses.
Step 4
Put every tag behind a consent condition
In Tag Manager, open each tag and add the consent requirement for its category: analytics tags need statistics consent, advertising and social pixels need marketing consent, and chat or personalisation tools need the matching category. Replace All Pages triggers on non-Google tags with your consent tool's trigger or event. Use preview mode and Tag Assistant to confirm that no tag in these categories fires on the first page view.
Step 5
Neutralise hard-coded scripts and embeds
Delete tracking snippets from theme files and switch off tracking options inside plugins and apps, then recreate them behind consent in one place. For scripts you cannot move, use the consent tool's blocking method, such as changing the script type until consent. Replace video, map and social embeds with click-to-load placeholders. Purge the page cache and CDN so no visitor is served an old page that still contains the early tags.
Step 6
Check what happens after Reject and after withdrawal
In a fresh private window, click Reject all, then browse several pages and confirm no advertising, recording or non-exempt analytics requests appear and no matching cookies are set. Next, accept everything, then reopen the cookie settings and withdraw consent. The tags should stop on the next page view, and the tool should delete the cookies it can. Check single-page apps as well, because route changes can keep sending events after withdrawal.
Step 7
Retest on real devices and schedule checks
Repeat the before-choice test on a phone, with the browser's own tracking protection both on and off, because some tags behave differently on mobile layouts. Run the GDPR Audit again and confirm the tracking finding has cleared. Then add the check to your release process: any new plugin, app, theme update or marketing tag should be followed by the same private-window test before it goes live to every visitor.
Server-side tagging, fingerprinting and email pixels
Server-side tagging
Moving tags to a server-side container changes where data is sent from, not whether consent is needed. If the setup still sets or reads cookies or identifiers in the visitor's browser for analytics or advertising, PECR still applies, and forwarding the data to vendors from your server is still processing under the UK GDPR. Server-side tagging can reduce what third parties receive, which is useful, but it is not a way around the banner.
Fingerprinting
Fingerprinting identifies a device by combining details such as screen size, fonts and browser settings instead of using cookies. The ICO has made clear that it regards fingerprinting as covered by the same rules on storage and access, and that it is harder for people to see and control. Treat any tool that fingerprints devices as needing consent, and be sceptical of vendors that sell "cookieless" tracking as a way to avoid asking.
Tracking pixels in emails
Open-tracking pixels in marketing emails read information from the recipient's device, and the ICO's guidance treats them as falling within the same rules. Explain open tracking when people sign up, and check your email platform's settings for disabling it for people who have not agreed.
1. How can I tell if my site is tracking visitors before they consent?
Open the site in a private browser window with the developer tools open and Preserve log ticked, and do not click anything on the banner. Filter the Network panel for domains such as google-analytics.com, facebook.com, doubleclick.net, clarity.ms and youtube.com, and look at the cookies in the Application panel. Any analytics, advertising or recording request or cookie that appears before you choose is tracking before consent. Repeat the test on several page types, because different templates often load different scripts.
2. Does Google Consent Mode make my site compliant on its own?
No. Consent Mode passes the visitor's choice to Google tags so they behave accordingly, but it does not show a banner, collect consent or control non-Google scripts. You still need a consent tool that asks properly, sets the default state to denied before any tag runs, and blocks other vendors' pixels. You also need to decide whether the advanced approach, which sends cookieless pings before consent, fits your position under PECR and UK GDPR.
3. Is it enough to delete cookies after a visitor clicks Reject?
No. PECR is about storing information on the device or reading it, so the moment a tracking script sets its cookie or reads an identifier, the thing that needed consent has already happened. Deleting the cookie afterwards does not undo it, and the script may already have sent data to the vendor. The script itself must be prevented from running until the visitor agrees to the matching category, and your tests should confirm that no request reaches the vendor before then.
4. Do YouTube and Google Maps embeds need consent?
Usually they need to be handled like other third-party content. When the iframe loads, the provider can set cookies or use browser storage, and the visitor's browser sends a request to the provider. The privacy-enhanced YouTube address reduces this but does not remove it. The common fix is a click-to-load placeholder: a still image with a short notice and a button, so the embed only loads when the visitor chooses to play or view it.
5. Does server-side tracking avoid the need for cookie consent?
Not by itself. Server-side tagging moves where data is sent from, but if your setup still stores or reads cookies or identifiers on the visitor's device for analytics or advertising, PECR consent rules still apply. The data you forward to vendors is also personal data under the UK GDPR, so you still need a lawful basis and transparency. It can reduce what third parties see, which is a benefit, but it is not an exemption.
6. Why does my Meta Pixel still fire after I installed a cookie banner?
Usually because it was added somewhere the banner does not control. Common causes are a snippet pasted into the theme header, a shop or marketing plugin with its own pixel setting, a Tag Manager tag firing on All Pages without a consent condition, or a cached page. Use the Initiator details in the Network panel to find which script loads the pixel, remove duplicates, and fire it once, only after marketing consent is given.
7. Can analytics run without consent under the new UK rules?
Possibly, in limited cases. The Data (Use and Access) Act 2025 adds a PECR exemption for collecting statistics to improve a website or service, with conditions including clear information and an easy, free way to object. It is being brought into force in stages and does not cover analytics used for advertising or shared with a vendor for its own purposes. Check the ICO's current guidance, and until you are sure an exemption applies, keep analytics behind consent.
The GDPR Audit checks what a visitor can see, including the cookie banner and the scripts that load before consent, and lists each finding with the guide that fixes it.
Open GDPR Fixes โ