Check 41.07 · Tracking and analytics setup

Handle applicable consent requirements

List your trackers, add a compliant banner, block what must be blocked and pass consent on to GA4, Tag Manager and Matomo on your CMS.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 h to 2 days
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

Handling consent means applying the rules of your visitors' country to the site's cookies and trackers: exempt ones run freely, the others wait for the visitor's explicit agreement, and the analytics tool receives the state of that consent. In France and the European Union, this requires a banner that lets visitors accept or refuse with the same ease. Once this is done, no tracker subject to consent fires before the visitor chooses, and measurement remains usable despite refusals.

This guide describes the technical implementation. It does not replace the advice of a lawyer or of your data protection officer.

Why it matters

In France, article 82 of the French Data Protection Act (loi Informatique et Libertés), which transposes the European ePrivacy Directive, requires prior consent before a tracker is placed on or read from the visitor's device, except where exemptions apply. The CNIL (the French data protection authority) sets out the rules: as long as the person has not consented, the cookies concerned can be neither placed nor read; accepting and refusing must be equally easy; withdrawing consent must be as easy as giving it; and the site must be able to prove the consent it collected. The CNIL regularly carries out inspections and imposes penalties on this subject.

A poorly connected banner also costs data: analytics tool blocked even after acceptance, landing page never measured, signals never passed on to Google.

Google also requires sites to obtain consent and to pass its state on. To serve personalized ads in the European Economic Area (EEA), the United Kingdom and Switzerland, AdSense, Ad Manager and AdMob require a Google-certified consent management platform (CMP) integrated with the IAB's TCF.

What it improves

  • Compliance Trackers conditional on the visitor's choice, proof of consent kept.
  • Measurement quality With Google's Consent Mode in its advanced version, GA4 receives cookieless signals from visitors who refuse and fills part of the gaps through modeling.
  • Trust A clear, honest banner is better received than a deceptive one.
  • Performance Blocking scripts until the visitor has chosen lightens the first load. See test before and after cookie consent (opens in a new tab).
  • Rankings No direct effect. A banner that hides the content can, however, hinder reading and the measurement of Core Web Vitals.

How to check

Private window, developer tools open (Network and Application > Cookies tabs), then three journeys:

  1. Arrival without a choice: no cookie subject to consent (_ga, _fbp, _gcl_au…) and no request to advertising domains.
  2. Refusal: same result, and the banner does not come back on the next page.
  3. Acceptance: the cookies appear and measurement is sent without reloading the page.

Also check the banner itself: a refuse button at the same level as the accept button, a link to the detailed purposes, a permanent way to change one's mind (a “Manage cookies” link in the footer).

For GA4, Tag Assistant shows the consent state of each event. The full checking method is in check data collection (opens in a new tab).

How to implement

Step 1 — List the trackers

Crawl or browse the site with the developer tools open, and list every cookie and every third-party script. Deliverable: a tracker register. Example (to adapt; it is not a legal assessment):

Tracker Provider Purpose Consent required? Lifetime
Session cookie, cart Site Operation No, strictly necessary Session
Cookie storing the banner choice Site or CMP Operation No Duration of the choice
_ga, _ga_<ID> Google Analytics 4 Audience measurement, data sent to Google Yes Up to 2 years by default
_pk_id Matomo configured according to the CNIL's conditions Exempt audience measurement No, under conditions 13 months recommended
_fbp Meta Advertising Yes Set by Meta
Embedded video player YouTube Playback and tracking Yes, in general: load it on click Set by Google

For audience measurement, the CNIL allows an exemption from consent if the tracker is used solely for audience measurement on behalf of the publisher only, produces anonymous statistics, and allows neither cross-referencing with other processing nor tracking across sites. It also recommends informing visitors, limiting tracker lifetime to 13 months and data retention to 25 months. GA4 is not among the solutions you can automatically consider exempt: check with the provider, using the CNIL's self-assessment tool.

Step 2 — Choose the banner

Solution Type Suited to
Platform's native banner Shopify, Wix, Squarespace Sites on these platforms with few third-party tools
Complianz, CookieYes, Cookiebot Plugins and CMPs WordPress, brochure sites and stores
Axeptio, Didomi, Cookiebot, OneTrust Commercial CMPs High-stakes, multi-country and advertising sites
tarteaucitron.js Open-source French script Custom sites, Laravel, Symfony, Next.js

Require: “Accept all” and “Reject all” buttons at the same level, choice by purpose, real prior blocking of scripts, integration of Google's Consent Mode, a consent log, and Google certification if you serve personalized ads through AdSense, Ad Manager or AdMob.

Mode How it works Consequence for GA4
Basic Google tags do not load before the visitor chooses Nothing is sent in case of refusal; general modeling only
Advanced Tags load with a default “denied” state and send cookieless signals No cookie before agreement; GA4 uses these signals to model part of the missing data

Four parameters control advertising and measurement: ad_storage, ad_user_data, ad_personalization and analytics_storage. Choosing between basic and advanced is as much a legal decision as a technical one: advanced mode sends requests, without cookies, before any consent. Have it approved.

Without a CMP that handles Consent Mode for you, set the default state before the Google tag:

<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>
<!-- Google tag (gtag.js) next -->

Then, in your banner's acceptance callback, send the update matching the accepted purposes (here, audience measurement only), and send it again whenever the choice changes:

gtag('consent', 'update', {
  'analytics_storage': 'granted',
  'ad_storage': 'denied',
  'ad_user_data': 'denied',
  'ad_personalization': 'denied'
});

wait_for_update gives the banner 500 milliseconds to pass on an already stored choice before the tags fire.

With Google Tag Manager

  1. Admin > Container Settings: turn on the consent overview.
  2. Add your CMP's tag from the Community Template Gallery, on the Consent Initialization - All Pages trigger, which fires before all others.
  3. Google tags (Google tag, Google Ads, Floodlight) have built-in checks: they read the consent state on their own.
  4. For every other tag (pixels, heatmaps), Advanced Settings > Consent Settings > Require additional consent for tag to fire, and add the required type (ad_storage for an advertising pixel).
  5. Preview the three journeys, then publish.

With Matomo

Two routes:

  • Exemption: configure Matomo according to the CNIL's conditions (IP address anonymization, no user ID, no cross-referencing, limited durations) and load it without waiting for the banner. Mention it in the privacy policy.
  • Consent: ask for it before any tracking.
var _paq = window._paq = window._paq || [];
_paq.push(['requireConsent']);
_paq.push(['trackPageView']);
// … rest of the Matomo tracking code

// In the banner's acceptance callback:
_paq.push(['rememberConsentGiven']);

// When consent is withdrawn:
_paq.push(['forgetConsentGiven']);

requireConsent blocks requests and cookies; requireCookieConsent sends requests but waits for agreement before setting cookies. rememberConsentGiven stores the agreement in the mtm_consent cookie: calling it once is enough.

WordPress

Versions WordPress 6.4 and later; Complianz, CookieYes, Cookiebot, WP Consent API and Site Kit by Google, November 2026 versions.

  1. Install a banner plugin (Complianz, CookieYes or Cookiebot) and run its wizard, which scans the site and blocks the scripts it recognizes.
  2. Install WP Consent API, which passes the choice on to compatible plugins.
  3. If GA4 goes through Site Kit: Site Kit > Settings > Admin Settings, turn on Consent Mode. Site Kit applies it to visitors from the EEA, Switzerland and the United Kingdom.
  4. If GA4 goes through Tag Manager, connect the CMP's template in GTM instead and turn off script insertion by the plugin.

Shopify

Versions Shopify admin, all plans, November 2026.

Settings > Customer privacy > Cookie banner. Publish a privacy policy first. Keep the automatic settings or choose the regions manually (EEA, United Kingdom, Switzerland), then the appearance and position. Shopify's banner governs the pixels managed by Shopify, including the Google & YouTube channel. Scripts added by hand in the theme or by apps may escape it: check them, or use a third-party CMP compatible with Shopify's Customer Privacy API, keeping the same regions on both sides.

Wix

Versions Wix dashboard, November 2026.

Turn on the built-in cookie banner in the privacy settings, with a reject button, and put each custom code snippet in its consent category.

Squarespace

Versions Squarespace 7.1, November 2026.

Cookies & visitor data panel: turn on the banner, type “Opt in & out”. Scripts added through Code Injection need your own consent logic.

Webflow

Versions Webflow, all site plans, November 2026.

Use a third-party CMP loaded in Site settings > Custom code, first in Head code, and have GA4 or GTM come after it with a default “denied” state. Check that no native integration injects a tag before the CMP.

PrestaShop

Versions PrestaShop 8 and 9.

Install a consent management module from PrestaShop Addons or one from a CMP (Axeptio, Didomi, Cookiebot), compatible with your version. Check that the Google Analytics module and the advertising modules wait for consent, then test the checkout.

Drupal

Versions Drupal 10 and 11.

The COOKiES, Klaro or EU Cookie Compliance modules display a banner and block scripts by category. With the Google Tag module, turn on its Consent Mode support if your version offers it, or handle it in Tag Manager.

Laravel

Versions Laravel 11 to 13.

At the top of the layout's <head>, in this order and inside a @production block: a partial containing the default state from step 3, the CMP script (tarteaucitron.js or a commercial CMP) with its configuration, then the Google tag. The CMP configuration calls gtag('consent', 'update', …) in its acceptance and refusal callbacks, as described in its documentation.

Next.js

Versions Next.js 15 and 16 (App Router).

// app/layout.tsx
import Script from 'next/script';
import { GoogleAnalytics } from '@next/third-parties/google';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="fr">
      <body>
        <Script id="consent-default" strategy="beforeInteractive">
          {`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>
        {children}
      </body>
      <GoogleAnalytics gaId="G-XXXXXXXXXX" />
    </html>
  );
}

The client-side banner component calls window.gtag('consent', 'update', …) when the visitor chooses and stores that choice.

Step 4 — Keep proof and review

  • Proof: the CNIL expects you to be able to demonstrate consent. Keep the CMP's log and dated screenshots of each version of the banner and its configuration.
  • Cookie policy: publish the up-to-date register from step 1, accessible from the banner and the footer.
  • Review: with every new tool, redo the inventory and the three journeys. Plan a check at least once a year.
  • Measurement: document the share of refusals and its effect on the figures. See document the limits of attribution (opens in a new tab).

Common mistakes

  • No reject button on the first layer, or a refusal hidden behind “Settings” while acceptance takes one click.
  • Decorative banner, the most frequent case: the choice is requested, but scripts fire before it or despite a refusal.
  • Pre-ticked boxes or consent inferred from continued browsing.
  • Landing page not measured after acceptance: the tag waits for the next page, and the source of the visit is lost.
  • Two competing systems (Shopify's native banner and a third-party CMP) with different regions: data are sent before the choice in some countries.
  • Consent Mode not passed on: GA4 and Google Ads receive no signal, and modeling cannot work.
  • Believing Matomo is exempt by nature: the exemption depends on its configuration.
  • Never updating the register after adding a chat, a video or a pixel.

Frequently asked questions

How long should audience measurement cookies be kept?

For audience measurement trackers exempt from consent, the CNIL recommends a lifetime of 13 months at most, with no automatic extension on each visit, and retention of the collected data for 25 months at most. These durations must be reviewed periodically. For other trackers, align the lifetime with the purpose and state it in your cookie policy.

Updated on

Topic checklist (PDF)

And now?

In the “Tracking and analytics setup” topic

  1. Set up Google Search Console
  2. Verify the domain property via DNS
  3. Set up Bing Webmaster Tools
  4. Set up GA4, Matomo or an equivalent
  5. Set up Google Tag Manager if needed
  6. Check data collection
  7. Handle applicable consent requirements
  8. Track conversions, forms and quote requests
  9. Track phone and email clicks
  10. Track downloads and sign-ups
  11. Track purchases
  12. Set up cross-domain tracking if needed
  13. Fix duplicate conversions
  14. Exclude internal traffic if relevant
  15. Identify organic and AI landing pages
  16. Create a dedicated channel for AI traffic
  17. Identify ChatGPT, Perplexity, Gemini, Copilot and Claude referrers
  18. Use available UTM parameters
  19. Connect analytics to the CRM if relevant
  20. Measure lead quality and revenue
  21. Document the limits of attribution
  22. Set up Consent Mode v2 if you use Google tags