Guides
Cookie consent
Configure the cookie banner and the preferences centre, and load scripts only with consent.
The landing pages include a cookie banner with a preferences centre. Everything is decided in the content of each landing (content/<landing>/<code>.ts, key cookies), so you never edit a component.
Piece | File | Purpose |
|---|---|---|
LandingCookieBanner | components/landing/LandingCookieBanner.vue | First-visit banner and an optional button to reopen it. |
LandingCookiePreferences | components/landing/LandingCookiePreferences.vue | Dialog with categories, switches and the cookie table. |
useCookieConsent() | composables/landing-page/useCookieConsent.ts | Reads the consent and opens the preferences from anywhere. |
1. Do you need a banner?
- No cookies, or only technical ones without a notice: remove
cookiesfrom the content. Nothing renders and the footer hides “Cookie settings”. - Only necessary cookies, but you want to inform:
mode: 'notice', a banner with a single “Got it” button. - Optional cookies (analytics, marketing…):
mode: 'opt-in'or'opt-out'depending on the law.
2. Pick the mode
mode | Before the visitor decides | Banner buttons | Typical laws |
|---|---|---|---|
opt-in (default) | Optional cookies **off** | Reject all, Accept all, Customise | GDPR + ePrivacy (EU, EEA), UK GDPR, LGPD (Brazil), nFADP (Switzerland) |
opt-out | Optional cookies **on** | Reject all, Accept all, Customise | CCPA/CPRA (California) and similar US state laws |
notice | Only necessary cookies | Got it | Sites without optional cookies |
If your audience is in several regions, use the strictest mode (opt-in). In the first two modes “Reject all” and “Accept all” have the same visual weight, as European authorities (EDPB, CNIL, AEPD) require.
3. Configure it
cookies: {
mode: 'opt-in',
version: '2026-10',
expiresInDays: 180,
reopenButton: false,
title: 'Your privacy, your choice',
policy: { label: 'Cookie policy', to: '/legal/cookies' },
categories: [
{
id: 'necessary',
required: true,
cookies: [{ name: 'landing-consent', provider: 'This site', duration: '6 months', purpose: 'Stores your choice' }],
},
{ id: 'analytics', cookies: [{ name: '_ga', provider: 'Google Analytics', duration: '2 years', purpose: 'Measures visits' }] },
{ id: 'chat', title: 'Support chat', description: 'Keeps the conversation open between pages.' },
],
},
Field | Default | Notes |
|---|---|---|
mode | opt-in | See the table above. |
version | 1 | Change it when you add cookies or change the policy: the banner shows again to everyone. |
expiresInDays | 180 | How often to ask again. CNIL recommends at most 13 months (about 395 days). |
reopenButton | false | A floating button to reopen. The footer link is always there. |
title, text | Texts from locales/<code>/landing.json | text has its own default for notice. |
policy | — | A LandingAction, shown in the banner and in the preferences. |
categories | necessary, analytics, marketing | necessary, preferences, analytics and marketing have translated titles; any other id needs a title. |
A category with required: true shows as “Always on”. If every category is required there is no preferences screen. cookies inside a category is optional; without it the category does not expand.
4. Load scripts only with consent
The banner does not block scripts by itself: you decide what loads.
const { hasConsent } = useCookieConsent()
watch(
() => hasConsent('analytics'),
(allowed) => {
if (allowed) loadAnalytics()
},
{ immediate: true }
)
Returns | Meaning |
|---|---|
hasConsent(id) | true if the category is required, accepted, or if the mode is opt-out and the visitor has not decided yet. |
hasDecided | The visitor chose with the current version. |
consent | { version, categories, updatedAt } as stored, read only. |
openPreferences() | Opens the preferences dialog. The footer link uses it. |
canCustomize | There are optional categories the visitor can change. |
The choice is stored in the landing-consent cookie, not in localStorage, so server and browser render the same thing. updatedAt records when consent was given; if your law requires storing it on a server, send it from a watch on consent.
Checklist before publishing
- A real list of cookies per category (name, provider, duration, purpose).
policypoints to a cookie policy page that exists.- No optional script loads without
hasConsent(). versionupdated if you changed cookies or the policy.