Prompt
How do I create a preference center for analytics, marketing, and functional cookies?
Latest observation
To create a cookie preference center for analytics, marketing, and functional cookies, you’ll want to combine a clear user interface with proper consent tracking and enforcement.
1) Define your cookie categories
Use simple, understandable groups:
- Necessary: required for the site to work; usually cannot be turned off
- Functional: remembers settings like language or region
- Analytics: helps measure traffic and usage
- Marketing: used for ads, retargeting, and personalization
2) Build the preference center UI
Create a modal/banner or settings page with:
- A short explanation of why cookies are used
- A toggle or checkbox for each category
- A “Reject all” and “Accept all” option
- A “Save preferences” button
- A link to your cookie policy / privacy policy
Recommended behavior:
- Necessary should be always on and not editable
- Analytics, Marketing, and Functional should be optional
- Default optional categories to off unless consent is already given
3) Store the user’s choices
Persist the user’s selections in a consent record, such as:
- A cookie
- Local storage
- A server-side profile, if the user is logged in
Include:
- Consent status for each category
- Timestamp
- Version of the consent text/policy
- Region/language if relevant
4) Block scripts until consent is given
Do not load analytics or marketing tags until the user opts in.
Examples:
- Analytics: Google Analytics, Matomo, Mixpanel
- Marketing: Meta Pixel, Google Ads, LinkedIn Insight Tag
Load them only after consent is granted for that category.
5) Allow users to change their preferences later
Add a persistent link in the footer or privacy menu:
- “Cookie preferences”
- “Privacy settings”
When clicked, it should reopen the preference center so users can update or withdraw consent anytime.
6) Keep auditability and compliance in mind
If you need to comply with laws like GDPR/UK GDPR/ePrivacy or similar rules:
- Log consent and withdrawals
- Make consent as easy to withdraw as to give
- Avoid pre-checked boxes for optional cookies
- Provide clear purposes for each category
- Don’t bundle unrelated purposes together
7) Example layout
You could present it like this:
-
Necessary cookies
Always on — needed for security and core site functions. -
Functional cookies
Remember your preferences and settings. -
Analytics cookies
Help us understand how visitors use the site so we can improve it. -
Marketing cookies
Used to deliver relevant ads and measure campaign performance.
Buttons:
- Accept all
- Reject all
- Save preferences
8) Implementation approach
A common technical pattern is:
- Show the banner on first visit
- Wait for the user to choose
- Save consent
- Load permitted scripts
- Re-check consent on future visits
- Provide a way to modify consent
If you want, I can also provide:
- a sample HTML/CSS/JavaScript preference center
- a React component
- or a Google Tag Manager setup for consent-based loading