How to Check Whether Your Cookie Banner Actually Blocks Tracking

A banner can be visible, interactive, and compliant-looking while tracking has already started underneath it. This guide shows how to test the actual browser behavior: what loads before a choice, what loads after rejection, and how to fix scripts, iframes, and SDKs that ignore consent.
The important question is not “does the banner appear?” It is “what does the browser send before the visitor chooses?” You can answer that without access to production credentials, analytics dashboards, or a consent vendor’s account. A clean browser profile and the browser’s DevTools are enough for a first, repeatable audit.
This article describes a testing method, not a result for any particular website. The examples use common names such as analytics.js, Google Analytics, Meta Pixel, and embedded video players. Your site may use different vendors, domains, or custom code.
What a successful test should prove
Before consent, a visitor should not trigger the non-essential tracking you have chosen to gate. That normally includes:
- requests to analytics or advertising endpoints;
- marketing cookies being written or sent;
- tracking pixels loading;
- third-party iframes starting activity;
- non-essential SDKs initializing in JavaScript.
After the visitor accepts a relevant category, those resources may load. After rejection, they should remain blocked, or the site should provide a documented alternative that does not perform the rejected processing.
Do not treat the absence of a visible cookie as proof that tracking is blocked. A site can send data in a request, store an identifier in another browser mechanism, or contact a vendor before any cookie appears.
A concrete failure pattern
Imagine a page that shows a consent banner on first visit. Its HTML contains this script:
<script src="https://example-analytics.test/analytics.js"></script>
<script>
analytics.init({ siteId: "example" });
</script>
The banner may cover the page until the visitor clicks “Accept,” but the browser still fetches analytics.js while parsing the document. The initialization code can then send a page-view request before the visitor has made a choice. Hiding the prompt changes the interface; it does not change the loading order.
A second common pattern is an embedded video or map:
<iframe
src="https://third-party.example/embed/123"
title="Embedded content">
</iframe>
The iframe may contact its own servers as soon as it is created. A consent banner outside the iframe cannot undo that request after the fact.
Prepare a clean test
Use a test page or staging environment when possible. If you test production, avoid entering personal information and do not submit forms during the audit.
- Open a private browsing window or create a fresh browser profile.
- Disable extensions that block or rewrite requests. Record which extensions you disabled.
- Open the browser menu and launch DevTools.
- Open the Network panel.
- Enable Preserve log and disable the browser cache for the current DevTools session.
- Clear site data for the origin if the browser profile is not new.
- Reload the page with the Network panel already open.
“Preserve log” matters because navigation can otherwise remove the evidence you need. A clean profile matters because an earlier consent decision can make the site behave as if the visitor already opted in.
Test one: before making a choice
Do not click Accept, Reject, Close, or any preference button yet. Watch the request list from the first document request onward.
Start with the Domain, Name, Type, and Initiator columns. The initiator often shows the script or document that caused a request.
Use the Network filter box to search for likely vendor names:
analytics
pixel
collect
track
gtag
facebook
doubleclick
segment
hotjar
clarity
youtube
vimeo
These are search terms, not a complete detection list. A vendor can use a first-party collection endpoint, a shortened hostname, a custom path, or a server-side proxy.
For every suspicious request, record:
- the full request URL, excluding personal query values when sharing notes;
- the request type;
- the initiator;
- the time or order in which it appeared;
- whether it contains an identifier or page information;
- whether it happened before the consent choice.
Click a request and inspect its Headers and Payload tabs. Look for fields such as page URL, referrer, client ID, session ID, campaign data, or advertising identifiers. Do not copy real user values into tickets, articles, or screenshots.
What counts as evidence before consent
A request is strong evidence of pre-consent activity when it is sent before a choice and its destination or payload indicates analytics, advertising, profiling, or another non-essential purpose. A script download alone may be enough to show that code was made available, but the stronger finding is an initialization or collection request caused by that script.
Classify the result carefully:
- Blocked: no relevant script, request, cookie, iframe, or SDK activity was observed before the choice.
- Loaded but inactive: a library was downloaded, but no relevant collection request was observed. This may still be unacceptable depending on the purpose and policy.
- Tracking observed: a relevant request or identifier was created before consent.
- Unclear: the vendor’s behavior cannot be determined from this test alone.
Test two: inspect cookies and storage
Open the Application panel and inspect storage for the tested origin. Check cookies, local storage, session storage, and other available storage areas.
Look for new entries created after the page load and before a choice. Names such as _ga, _fbp, mp_*, or amplitude_* can be clues, but names are not proof. A first-party cookie may support essential functionality, and an unfamiliar name may belong to the consent system itself.
Use the cookie’s domain, path, expiration, and value format together with the Network evidence. When sharing a screenshot, mask values and identifiers.
Test three: reject non-essential categories
Reload the clean page, then choose the strongest available rejection option, such as “Reject all” or a preference setting that disables analytics and marketing. If the banner only offers “Accept” and “Close,” record that limitation rather than treating Close as rejection.
After rejection:
- reload the page with Network logging preserved;
- repeat the vendor-name searches;
- check whether new tracking requests appear;
- inspect storage for newly created identifiers;
- open the Elements panel and check whether blocked iframes were replaced by placeholders or removed.
Then navigate to another page on the same site. A banner can behave correctly on the landing page and fail on a template that includes a different tag manager container, video component, or marketing script.
Test four: accept one category at a time
If the banner supports granular preferences, test each category separately. Start with all non-essential categories rejected, then enable one category and reload.
This isolates which consent signal unlocks which resource. For example, analytics may be allowed while marketing remains blocked. The result should be reflected in the site’s behavior, not only in the banner’s checkboxes.
Record the sequence:
Initial load → no choice → reject all → reload
Initial load → no choice → allow analytics only → reload
Initial load → no choice → allow marketing only → reload
Initial load → no choice → accept all → reload
Be aware that some systems apply a choice without a full reload, while others initialize on the next navigation. Test both the immediate behavior and a fresh navigation after the choice.
Inspect scripts, iframes, and SDKs in the page
Scripts
In the Elements panel, search for <script. Pay particular attention to:
- external scripts whose host belongs to an analytics or advertising vendor;
- inline code containing
gtag,fbq,dataLayer,analytics, ortrack; - tag-manager containers that can load additional tags;
- scripts inserted dynamically after the initial document load.
Use the Initiator tab for a request to trace which script created it. An external library may be only the first step; the real collection call can be made by an inline bootstrapper or a tag manager.
iframes
Search for <iframe and compare the DOM before and after consent. For non-essential embeds, the pre-consent DOM should contain a placeholder, a click-to-load control, or no third-party iframe at all.
Changing an iframe’s CSS to display: none is not sufficient. The browser can still load the iframe’s src. The safe pattern is to delay assigning src until the required consent exists.
SDKs and tag managers
An SDK can initialize without immediately setting a cookie. It may register event listeners, generate an identifier in memory, or prepare data for a later request. Search the console and Sources panel for initialization calls, but treat the Network panel as the primary evidence for data leaving the browser.
Tag managers deserve a separate check because one container can load tags from several vendors. A banner that blocks one script URL does not necessarily block tags injected by the container.
How to fix pre-consent loading
The fix is to make consent a prerequisite for initialization, not a visual layer placed over already-running code.
Gate the script element
Do not include a non-essential script in the initial HTML. Add it only after the relevant consent signal is available:
<script>
function loadAnalytics() {
if (window.analyticsLoaded) return;
window.analyticsLoaded = true;
const script = document.createElement("script");
script.src = "https://example-analytics.test/analytics.js";
script.async = true;
script.onload = () => {
window.analytics.init({ siteId: "example" });
};
document.head.appendChild(script);
}
function onConsentChanged(consent) {
if (consent.analytics === true) {
loadAnalytics();
}
}
</script>
The event name and consent object depend on your consent system. The important properties are that the script is absent before permission, initialization happens once, and the code responds to the actual consent state.
Gate inline initialization
Removing an external script is not enough if inline code still sends events or calls a previously available library. Wrap initialization and event collection in the same consent check.
if (consent.analytics === true) {
analytics.init();
analytics.page();
}
Also inspect automatic page-view settings. A library may send a page view as soon as it initializes, before your application code has finished applying preferences.
Gate iframes by delaying src
<div
class="video-placeholder"
data-embed-src="https://video.example/embed/123"
data-consent-category="functionality">
Video unavailable until you allow the required category.
</div>
<script>
function activateEmbeds(category) {
if (category !== "functionality") return;
document.querySelectorAll("[data-embed-src]").forEach((placeholder) => {
const iframe = document.createElement("iframe");
iframe.src = placeholder.dataset.embedSrc;
iframe.title = "Embedded video";
iframe.loading = "lazy";
placeholder.replaceWith(iframe);
});
}
</script>
Do not put the third-party URL in an iframe’s src before consent. A placeholder may display a preview image hosted by your own site, provided that the preview itself does not send the blocked data.
Configure the tag manager at its source
If a tag manager is responsible for the request, blocking a visible script in the page may not solve the problem. Configure each tag’s consent requirement in the tag manager and verify the container’s default state before consent.
Use the tag manager’s preview mode only as an aid. The browser’s Network log remains the final check for what was actually requested.
Verification after the fix
Repeat the full test in a fresh profile. Do not rely on the browser state from the development session, because an earlier acceptance can make a broken implementation look correct.
A useful verification record contains:
- browser and version;
- test URL and environment;
- fresh-profile or cleared-storage method;
- consent choice made;
- relevant request URL or host;
- request initiator;
- storage changes;
- expected result and observed result.
For an automated regression check, use a browser test that clears storage, opens the page, waits for the banner, and fails if a known tracking host is requested before consent. Keep the host list maintained; a test that checks only one vendor can miss a newly added integration.
// Illustrative Playwright-style test
const trackingHosts = [
"example-analytics.test",
"example-advertising.test"
];
page.on("request", request => {
const url = new URL(request.url());
if (trackingHosts.some(host => url.hostname.endsWith(host))) {
throw new Error(`Tracking request before consent: ${url.hostname}`);
}
});
await page.goto("https://example.test/");
await page.waitForSelector("[data-consent-banner]");
This is an example, not a verified test for your site. Adapt the selector, host list, consent categories, and timing to the implementation under review.
Failure cases and misleading signals
“I saw no cookies, so it is blocked”
Cookies are only one storage and transmission mechanism. Check requests, local storage, script initialization, and third-party connections as well.
“The request is first-party, so it is harmless”
A first-party endpoint can proxy data to an analytics or advertising system. Inspect the path, payload, initiator, and server-side design before classifying it.
“The banner blocks the page, so scripts cannot run”
A modal overlay does not pause the browser’s parser or JavaScript event loop. Scripts can load and execute behind it.
“Reject worked once”
The result may be cached in local storage or a consent cookie. Repeat the test from a clean state and test navigation to another page.
“The vendor is listed as necessary”
The label is a configuration decision, not browser evidence. Confirm what the integration actually does and document the basis for the category.
“The page is clean, but the checkout is not”
Different templates, subdomains, and applications can use separate containers and consent states. Test representative routes, including authenticated and embedded flows when they are in scope.
Limitations of a browser-only audit
DevTools shows what happened in the tested browser session. It cannot prove that every geography, device, route, feature flag, or server-side integration behaves identically.
A browser test also may not reveal:
- server-side tracking triggered by a form submission;
- data sent by a native mobile application;
- processing performed after a first-party server receives an event;
- behavior behind login or a feature flag you did not receive;
- vendor behavior that changes over time.
Use the result as bounded evidence: “this request was observed in this browser, on this route, in this consent state.” That statement is more useful and defensible than a blanket claim that the entire site is compliant or non-compliant.
Practical checklist
- Start with a fresh profile or cleared site data.
- Open Network logging before loading the page.
- Preserve the log and disable cache for the test.
- Record requests before making any choice.
- Inspect initiators, payloads, cookies, and other storage.
- Reject non-essential categories and repeat the test.
- Accept one category at a time and compare the results.
- Inspect script tags, dynamically inserted scripts, iframes, SDKs, and tag-manager containers.
- Delay loading and initialization until the correct consent exists.
- Repeat the test after the fix and preserve the evidence.
A trustworthy cookie banner is the visible part of a loading policy. The policy is working only when the browser’s requests, storage, scripts, iframes, and SDK initialization match the visitor’s choice.
Continue with the Agent Lab Journal guides or look up implementation terms in the glossary.