In short
The same page exists in three versions: with the consent banner displayed, after acceptance (all the analytics and advertising scripts load) and after refusal. Automated testing tools only see the first one. Visitors who accept experience the second, which is sometimes much slower. This check consists of measuring all three states, identifying what the banner and the scripts triggered by acceptance cost, then closing the gap. All while staying compliant: no tracker that requires consent loads before the visitor agrees.
Why it matters
PageSpeed Insights, Lighthouse and most lab tools load the page as a new visitor, without cookies, and do not interact with it. They therefore measure the page with the banner, before any choice is made. Two blind spots follow:
- The banner itself skews or degrades the measurement. On mobile, its block of text can become the largest visible element, and therefore the LCP (Largest Contentful Paint) element. Inserted into the page flow, it shifts the page and weighs on CLS (Cumulative Layout Shift). Its script, loaded in a blocking way, delays the first display.
- The post-acceptance state is never tested. When the visitor clicks “Accept”, the tag manager fires analytics, advertising pixels and session recording tools all at once. This click can be the slowest interaction of the visit, and every following page loads with these scripts.
Field data (Chrome User Experience Report, Search Console) mixes the three states: this is why a flattering lab score sometimes coexists with poor real-world Core Web Vitals.
What it improves
- Diagnostic reliability You know what share of the slowness comes from the site, the banner or the scripts that require consent.
- INP (Interaction to Next Paint, the responsiveness to interactions): the acceptance click and the pages loaded afterwards are the first to benefit.
- LCP and CLS A lightweight overlay banner no longer delays display or shifts the page.
- Field Core Web Vitals These are the ones Google uses. The effect on rankings remains indirect.
- Compliance Testing the initial state checks, along the way, that no tracker fires before the visitor's choice.
How to check
A five-minute check in Chrome:
- Open an incognito window, then the developer tools, Network tab, with the “Disable cache” box checked.
- Load the page without touching the banner. Note the number of requests and the amount transferred at the bottom of the tab. Filter with
More filters > 3rd-party requests: only the consent tool and strictly necessary services should appear. - Click “Accept”. Watch the new requests.
- Reload the page: note the requests and transfer size again.
To count the third-party domains at each step, in the console:
new Set(
performance.getEntriesByType('resource')
.map((entry) => new URL(entry.name).hostname)
.filter((host) => host !== location.hostname)
).size;
Compliant result: no tracker requiring consent before the choice, and an “accepted” state whose gap with the initial state is known, quantified and deemed acceptable.
How to implement
Step 1 — Define the states to measure
| State | What loads | How to reproduce it |
|---|---|---|
| First visit | page, consent tool, banner | incognito window, no click |
| Acceptance click | all tags fire | record the interaction |
| Visits after acceptance | page and all consented scripts | reload after accepting |
| Visits after refusal | page only, no banner | clear site data, refuse, reload |
Measure these states on your main templates (home, list, product page, article), on mobile with network and CPU throttling. See test on a slow mobile connection (opens in a new tab).
Warning: these tests simulate a visitor's choice in your own test browser. They never justify pre-recording consent for real visitors, or loading a script that requires consent before they agree.
With Chrome's developer tools
- Incognito window, Performance tab, CPU and network throttling enabled.
- Start recording with a page reload: you get the LCP and CLS of the first visit. Look at which element is identified as the LCP: if it is the banner, the measurement does not reflect your content.
- Start a new recording, click “Accept”, stop after a few seconds. The Interactions track gives the duration of the click; the long tasks that follow show which scripts occupy the main thread.
- Record a reload: this is the “after acceptance” state.
To get a Lighthouse report in the accepted state, open the Lighthouse tab, uncheck the clear storage option in its settings, then run the analysis after accepting the banner. Compare it with a report run in an incognito window.
With Lighthouse on the command line
Lighthouse user flows, driven by Puppeteer, chain the three measurements in a single report. Install both packages (npm install lighthouse puppeteer), then create consentement.mjs, adapting the button selector:
import { writeFileSync } from 'node:fs';
import puppeteer from 'puppeteer';
import { startFlow } from 'lighthouse';
const url = 'https://example.com/';
const acceptButton = '#bouton-accepter';
const browser = await puppeteer.launch();
const page = await browser.newPage();
const flow = await startFlow(page);
await flow.navigate(url, { name: 'First visit, banner displayed' });
await flow.startTimespan({ name: 'Click on Accept' });
await page.click(acceptButton);
await new Promise((resolve) => setTimeout(resolve, 5000));
await flow.endTimespan();
await flow.navigate(url, {
name: 'Visit after acceptance',
disableStorageReset: true,
});
writeFileSync('consentement.html', await flow.generateReport());
await browser.close();
node consentement.mjs
Open consentement.html: each step has its own metrics. Option names change from one version to another: refer to the user flows documentation for your version of Lighthouse.
With WebPageTest
WebPageTest accepts a script that sets the consent cookie before navigation. Get the cookie's name and value from your browser after accepting (developer tools, Application tab, Cookies section), then paste the following into the script field, separating the items with tabs:
setCookie https://example.com COOKIE_NAME=VALUE
navigate https://example.com/
Run one test without a script and one with it, then compare the waterfalls. If your consent tool stores the choice somewhere other than a cookie (local storage), use the Lighthouse method instead.
Step 2 — Lighten the banner
- Load the consent tool with
asyncand from a preconnected domain. A blocking banner script in the<head>delays the entire render. - Display the banner as an overlay, at the bottom of the screen (
position: fixed), so that it does not shift the content. See reserve space for media and ads (opens in a new tab). - Keep the text short on mobile with a link to the details: a banner smaller than your heading or main image does not become the LCP element.
- Avoid entrance animations that move the banner within the flow.
- Leave the content readable behind the banner. Google states that banners that meet a legal obligation are not treated as intrusive interstitials; an opaque wall that hides the whole page is still a poor experience. See avoid intrusive interstitials (opens in a new tab).
Step 3 — Lighten the post-acceptance state
The acceptance click should first close the banner, and only then fire the tags. Yield to the browser in between:
function onConsentGranted() {
closeBanner();
requestAnimationFrame(function () {
setTimeout(loadConsentedTags, 0);
});
}
Then treat the consented scripts like any other third-party script: inventory, removal of duplicates, late loading. See limit third-party scripts (opens in a new tab).
With Google tags, declare the default Consent Mode state before the Google Tag Manager container, and let the consent tool send the update when the choice is made:
<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',
wait_for_update: 500
});
</script>
In Google Tag Manager, make each tag conditional on the type of consent it requires (the tag's consent settings) rather than firing everything on a single event. See handle applicable consent requirements (opens in a new tab).
Step 4 — Monitor over time
Add the Lighthouse flow to your recurring checks and record in your performance budget (opens in a new tab) a limit for the accepted state (number of third-party requests, Total Blocking Time). Measure again after every new marketing tag.
In France, some analytics solutions can be exempt from consent under strict conditions set by the CNIL, the French data protection authority. If yours is one of them and collects Core Web Vitals, you can compare visits in it according to consent state. Check these conditions with your data protection officer before relying on them.
WordPress
Versions WordPress 6.4 to 7.1, with the November 2026 versions of the plugins mentioned.
Consent plugins (Complianz, CookieYes, Cookiebot, Axeptio, tarteaucitron) inject their script and block known trackers until the choice is made. Points to check:
- Page cache: the banner must be displayed by JavaScript based on the visitor's cookie, not written into the cached HTML. Otherwise, visitors who have already answered see it again, or the other way round.
- Script optimization: exclude the consent script from the options that delay JavaScript until the first interaction (WP Rocket, LiteSpeed Cache, Perfmatters). When delayed, it lets through the scripts it was supposed to block, or displays the banner late.
- Scripts added by hand in the theme or through a code insertion plugin: the consent plugin does not know about them. Route them through its blocking mechanism, then test the initial state again.
Shopify
Versions Shopify admin, all plans, November 2026.
The native banner is configured in Settings > Customer privacy > Cookie banner. Pixels declared in Settings > Customer events respect the visitor's choice and run in an environment isolated from the page. Scripts pasted directly into theme.liquid are not conditional: move them to customer events or make them conditional with Shopify's Customer Privacy API. Then test the states on the home page, a collection and a product page.
Cloudflare
Versions Cloudflare Zaraz, Cloudflare dashboard, all plans, November 2026.
Zaraz includes a consent manager: each configured tool is linked to a purpose and only runs after consent. A newly added tool has no purpose by default and then loads without waiting for consent: assign one to it in the consent manager's purposes section. As compatible tools run on Cloudflare's side, the gap between the initial state and the accepted state is smaller in the browser. Consent is still required under the same conditions: server-side execution does not replace it.
Common mistakes
- Relying only on the PageSpeed Insights score: it sees neither the acceptance nor the following pages.
- Testing while logged in or with a browser that has already answered the banner: you are not measuring the first visit.
- Optimizing by loading trackers before the choice, or by pre-selecting acceptance: this is an infringement, not an optimization.
- Delaying the consent script along with the others: trackers fire without control, or the banner appears late and shifts the page.
- Firing every tag synchronously on click: the main thread is saturated and the interaction gets longer, especially on mobile.
- Forgetting the “refused” state: some sites keep loading unnecessary scripts in it, or show the banner again on every page.
- Measuring a single page: templates do not carry the same tags.
Frequently asked questions
Does PageSpeed Insights test the page after cookies are accepted?
No. PageSpeed Insights, Lighthouse and most lab tools load the page as a new visitor, without cookies, and do not interact with it: they measure the page with the banner, before any choice. The scripts triggered by acceptance therefore do not appear. Measure that state with Chrome's developer tools, a Lighthouse user flow or a WebPageTest script.
Can the cookie banner become the LCP element?
Yes, especially on mobile: if its block of text is larger than your heading or main image, it becomes the largest visible element, and the LCP then measures the banner rather than your content. Keep the text short on mobile with a link to the details, load the consent tool with async and display the banner as an overlay at the bottom of the screen.
Can analytics scripts be loaded before consent to gain performance?
No. Loading a tracker that requires consent before the visitor agrees, or pre-selecting acceptance, is an infringement, not an optimization. Tests that simulate a choice in your test browser never justify pre-recording consent for real visitors. Close the gap in other ways: a lightweight banner, tags fired after the banner closes, and an inventory of the consented scripts.
Why is clicking “Accept all” often slow?
Because it triggers the loading and execution of every tag at once: analytics, advertising pixels, session recording tools. The main thread is saturated and the interaction gets longer, which weighs on INP. Close the banner first, yield to the browser, then fire the tags; in Google Tag Manager, make each tag conditional on the type of consent it requires.
Resources
- CNIL: Cookies and other trackers (in French)cnil.fr
- CNIL: Analytics solutions exempt from consent (in French)cnil.fr
- web.dev: Best practices for cookie noticesweb.dev
- Google: Set up consent modedevelopers.google.com
- Lighthouse: User flowsgithub.com
- WebPageTest: Scriptingdocs.webpagetest.org
- Google Search Central: Interstitials and dialogsdevelopers.google.com
- Shopify: Customer privacy settingshelp.shopify.com
Updated on
Topic checklist (PDF)