A website can display a cookie consent banner and still load advertising pixels, analytics scripts and third-party trackers before the visitor makes a choice.
For developers, this is an implementation problem, not just a banner-design problem.
A correct consent implementation must establish the appropriate default state early, control configured non-essential scripts and update behaviour when visitors accept, reject or withdraw consent.
This guide covers the practical implementation considerations.
1. Understand What You Need to Block
Third-party cookies are associated with domains other than the website being visited.
Common sources include:
- Advertising networks.
- Analytics platforms.
- Social media pixels.
- Retargeting tools.
- External video embeds.
- Marketing automation services.
However, cookie blocking is not the same as complete tracking prevention.
A script may use local storage, session storage, pixels, browser APIs or network requests without relying exclusively on third-party cookies.
Start by creating a tracker inventory.
| Technology | Inspect |
|---|---|
| Analytics | Cookies, storage and network requests |
| Advertising | Pixels and advertising identifiers |
| Social media | External scripts and pixel requests |
| Video embeds | External requests and storage |
| Chat widgets | Third-party scripts and identifiers |
Use Chrome Developer Tools to inspect Application and Network panels.
2. Establish the Consent State Before Other Tags
One common implementation mistake is loading the CMP asynchronously while other tracking scripts execute immediately.
The sequence matters.
A safer architecture is:
- Establish the applicable default consent state.
- Initialise the consent management integration.
- Display the consent interface.
- Wait for the visitor's choice.
- Update consent states.
- Activate only permitted technologies.
Google recommends establishing default consent before commands that send measurement data.
Official guide: https://developers.google.com/tag-platform/security/guides/consent
3. Google Consent Mode v2
Google Consent Mode allows supported Google tags to respond to visitor consent.
Relevant parameters include:
[
"ad_storage",
"analytics_storage",
"ad_user_data",
"ad_personalization",
"functionality_storage",
"personalization_storage",
"security_storage"
]
An illustrative gtag.js default state:
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('consent', 'default', {
'ad_storage': 'denied',
'analytics_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied'
});
</script>
This example only establishes default consent states for the specified Google consent types.
It does not automatically block every third-party script.
Basic vs Advanced Consent Mode
Basic Consent Mode
- Google tags are blocked until the visitor interacts with the banner.
- No data is sent to Google through those tags before interaction.
- If the visitor does not consent, the tags remain blocked.
Advanced Consent Mode
- Google tags load with configured default consent states.
- While consent is denied, supported tags may send cookieless pings.
- Tag behaviour changes when the visitor updates consent.
Official documentation: https://developers.google.com/tag-platform/security/concepts/consent-mode
If the requirement is to prevent Google tags from loading until the visitor makes a choice, evaluate Basic Consent Mode.
4. Configure Google Tag Manager Correctly
Google Tag Manager provides a Consent Initialization trigger.
It is designed for tags that establish or update consent settings before other triggers execute.
Suggested implementation:
- Add the CMP's supported GTM template, if available.
- Configure the CMP tag to use Consent Initialization - All Pages.
- Configure consent requirements for relevant tags.
- Check the Consent Overview in GTM.
- Test the container using Preview mode.
- Verify actual network requests.
Google documentation: https://support.google.com/tagmanager/answer/10718549
Avoid relying on a custom HTML tag with incorrectly sequenced consent commands. For custom templates, use the Tag Manager consent APIs.
5. Script Blocking for Other Third-Party Services
Google Consent Mode is not a universal third-party script blocker.
Your website may also load:
- Meta Pixel.
- LinkedIn Insight Tag.
- Hotjar.
- Advertising networks.
- External chat widgets.
- Embedded media.
These technologies need their own consent-aware execution rules where applicable.
A CMP may provide prior-script blocking or automatic script blocking to manage configured scripts.
For example:
- ConsentX offers prior-script blocking on its paid plans.
- CookieYes documents automatic cookie blocking and prior-consent implementation.
Documentation:
- https://www.consentx.io/features
- https://www.cookieyes.com/documentation/implement-prior-consent-using-cookieyes/
Do not assume that installing a CMP automatically covers every script. Check its configuration and test the actual website.
6. A Practical Test Plan
Use a clean browser session for every test.
| Test | Expected result |
|---|---|
| Initial page load | Consent interface appears |
| Before consent | Configured non-essential trackers remain inactive |
| Reject analytics | Analytics requiring consent remains blocked |
| Reject advertising | Advertising trackers remain blocked |
| Accept analytics | Permitted analytics activates |
| Change preferences | Consent state updates |
| Reload page | Stored preferences are respected |
| Withdraw consent | Relevant tracking stops as required |
Inspect:
- Cookies.
- Local storage.
- Session storage.
- Network requests.
- GTM Preview.
- Tag Assistant.
Google's debugging documentation is useful for identifying consent implementation errors:
https://developers.google.com/tag-platform/security/guides/consent-debugging
7. Common Implementation Errors
CMP loads after tracking scripts
The default consent state may be established too late.
Fix: Initialise consent before relevant tracking tags.
Consent Mode is treated as a universal blocker
Other third-party scripts may still execute.
Fix: Configure separate blocking rules for non-Google technologies.
Only cookies are inspected
Other storage technologies and network requests may be missed.
Fix: Inspect the complete tracking behaviour.
Withdrawal is not tested
A visitor's updated choice may not stop subsequent tracking.
Fix: Test preference changes and revocation.
8. What Should You Look for in a CMP?
A CMP should be evaluated based on:
- Prior-script blocking.
- Regional consent rules.
- Google Consent Mode integration.
- Cookie and tracker discovery.
- Consent receipts.
- Preference withdrawal.
- Multi-site management.
- Integration compatibility.
ConsentX offers prior-script blocking, regional rules, consent receipts and Google Consent Mode v2 as part of its feature set.
CookieYes offers automated scanning, cookie categorisation, automatic blocking and consent logs.
Compare both against your actual implementation requirements.
Conclusion
Blocking third-party cookies before consent requires correct sequencing, script controls and repeatable testing.
Google Consent Mode helps supported Google tags respond to consent signals, but it does not replace broader script-blocking controls.
Use a CMP to centralise consent management, configure each relevant tracking technology and verify the implementation through browser storage and network inspection.
A banner is only the interface. The actual consent behaviour is what matters.
Top comments (0)