GDPRChecker

Home / Knowledge Base / Next.js Cookie Compliance in Spain: Cookie Consent Implementation and Testing Guide

Website Compliance

Next.js Cookie Compliance in Spain: Cookie Consent Implementation and Testing Guide

A practical guide for Next.js developers and website owners to implement cookie consent in compliance with Spanish GDPR and ePrivacy rules. Covers step-by-step CMP integration, Google Consent Mode v2 setup, server-side considerations, common mistakes, and validation using GDPRChecker’s scanner. Includes a checklist, comparison table, real-world examples, and FAQ.

Author

GDPRChecker Editorial Team

Reviewed by

Privacy & Compliance Research Team

Last updated

August 2026

Reading time

16 min read

Educational guidance for compliance readiness — not legal advice. Requirements vary by jurisdiction and your specific processing activities.

Introduction

*Updated for 2026 compliance practices.*

If you run a Next.js website that serves visitors from Spain, achieving proper cookie compliance is not just a legal checkbox—it’s a continuous technical challenge. The Spanish Data Protection Authority (AEPD) actively enforces GDPR and the national ePrivacy rules, often issuing fines for non-compliant cookie banners, pre-consent tracking, and missing disclosures. This guide provides a practical, step-by-step approach to implementing and testing cookie consent on a Next.js site, tailored to the Spanish regulatory environment. You’ll learn how to configure your consent management platform (CMP), integrate Google Consent Mode v2, validate your setup with GDPRChecker’s scanner, and avoid the most common pitfalls that trip up developers and site owners.

**What this guide covers:** - The specific requirements for cookie compliance in Spain and how they apply to Next.js applications. - A detailed implementation walkthrough, from choosing a CMP to configuring consent-aware tags. - Testing strategies using GDPRChecker to catch pre-consent network requests, banner behavior issues, and disclosure gaps. - A practical checklist and FAQ to keep your site compliant over time.

This is a technical implementation guide, not legal advice. Always consult a qualified privacy lawyer for your specific situation. For official references, see the European Data Protection Board and the GDPR.eu overview.

Common Mistakes and How to Avoid Them

Even well-intentioned developers make mistakes that can lead to non-compliance. Here are the most frequent issues we see in Next.js projects and how to fix them.

1. Pre-Consent Network Requests

**Mistake:** Loading analytics or marketing scripts before the user has given consent. This often happens when scripts are placed in `_document.js` without consent checks or when Next.js’s `<Script>` component uses `beforeInteractive` for non-essential scripts.

**How to avoid:** Always set default consent to denied and load scripts only after consent is updated. Use GDPRChecker’s scanner to detect any pre-consent requests. The scanner will flag requests to known tracking domains that fire before consent.

2. Missing or Ineffective Reject Button

**Mistake:** The cookie banner has an “Accept” button but the “Reject” option is hidden behind a settings link or is less prominent.

**How to avoid:** Ensure the “Reject all” button is as visually prominent as “Accept all.” Test this with GDPRChecker’s banner behavior checks, which verify that both options are present and equally accessible.

3. Incorrect Consent Mode Implementation

**Mistake:** Setting default consent to `'granted'` or not updating consent after user interaction. This causes Google tags to fire as if consent were given, even when it’s not.

**How to avoid:** Follow Google’s official Consent Mode documentation. Use GDPRChecker’s Consent Mode diagnostics to confirm that consent states are correctly passed to Google tags.

4. Ignoring Server-Side Rendering (SSR) Pitfalls

**Mistake:** Embedding tracking pixels in server-rendered HTML that execute before any client-side consent check.

**How to avoid:** Never include third-party tracking scripts in SSR output unless they are strictly necessary. Use client-side only loading with consent wrappers.

5. Not Testing After Changes

**Mistake:** Deploying a new feature or updating a script without re-scanning for compliance.

**How to avoid:** Integrate GDPRChecker into your CI/CD pipeline or manually scan after every significant change. This catches new cookies, missing disclosures, or broken consent flows.

How to Validate with GDPRChecker

GDPRChecker provides a comprehensive scanning engine that helps you verify every aspect of your Next.js cookie compliance. Here’s how to use it effectively.

1. Pre-Consent Request Scan

Run a scan to see which network requests fire before any consent is given. GDPRChecker will list all third-party domains contacted and highlight those that set cookies. If you see analytics or marketing domains, your implementation needs fixing.

2. Banner Behavior Check

GDPRChecker simulates user interactions with your cookie banner. It checks: - Is the banner displayed on first visit? - Are “Accept all” and “Reject all” options present and equally prominent? - Does the banner reappear if consent was previously given? (It should not, unless cookies were cleared.) - Is the privacy policy link present and working?

3. Consent Mode Diagnostics

If you use Google Consent Mode, GDPRChecker verifies that: - Default consent is set to denied for ad_storage and analytics_storage. - Consent updates are sent correctly after user interaction. - Google tags (gtag.js, GTM) respect the consent state.

4. Cookie Inventory and Classification

GDPRChecker crawls your site and builds a cookie inventory. It classifies cookies by category and checks if they are declared in your cookie policy. Any undeclared cookies are flagged.

5. Policy Link and Disclosure Verification

The scanner ensures that your cookie banner links to a valid cookie policy and that the policy contains all required information (cookie list, purposes, durations, third parties).

**Real-world example:** A Spanish news site used GDPRChecker after implementing a new CMP. The scan revealed that a legacy Twitter widget was still loading before consent. The team fixed the widget to load conditionally and rescanned to confirm compliance.

For a complete verification workflow, see our Google Consent Mode v2 checker guide.

Real-World Examples

Example 1: Spanish E-commerce Site A medium-sized online store built with Next.js was using Google Analytics and Facebook Pixel. Their initial implementation loaded both scripts in `_document.js` without consent checks. After a GDPRChecker scan flagged pre-consent requests, they: - Moved scripts to a client-side consent wrapper. - Implemented Consent Mode v2 for Google tags. - Added a CMP with a clear reject button. - Rescanned and confirmed zero pre-consent requests.

Example 2: Spanish News Portal A high-traffic news site used server-side rendering for performance. They had embedded a Twitter timeline widget that fired requests on every page load. GDPRChecker detected these as pre-consent third-party requests. The fix: - Replaced the server-embedded widget with a client-side component that loaded only after consent. - Updated the cookie policy to declare Twitter as a third party.

Example 3: SaaS Landing Page A SaaS company’s Next.js landing page had a simple cookie banner but no reject button—only an “Accept” button and a link to settings. The AEPD would consider this non-compliant. After reading this guide, they: - Redesigned the banner with equally prominent “Accept” and “Reject” buttons. - Verified with GDPRChecker’s banner behavior check.

FAQ

What is Next.js cookie compliance Spain cookie consent implementation and testing guide? This guide provides a technical walkthrough for implementing cookie consent on Next.js websites to comply with Spanish regulations. It covers CMP setup, Consent Mode v2 integration, server-side considerations, and testing with GDPRChecker to ensure no pre-consent tracking occurs and all disclosures are correct.

Do I need Next.js cookie compliance Spain cookie consent implementation and testing guide for GDPR? If your Next.js site serves users in Spain and uses non-essential cookies, you must comply with the GDPR and Spanish ePrivacy rules. This guide helps you implement the necessary technical measures, but you should also seek legal advice to ensure full compliance with all applicable laws.

How do I implement Next.js cookie compliance Spain cookie consent implementation and testing guide? Implement by: 1) installing a CMP that blocks scripts by default, 2) integrating Google Consent Mode v2 with denied defaults, 3) conditionally loading third-party scripts based on consent, 4) handling server-side cookies carefully, and 5) updating your privacy and cookie policies. Then test with GDPRChecker.

How can I verify Next.js cookie compliance Spain cookie consent implementation and testing guide with a scanner? Use GDPRChecker to scan your site. It checks for pre-consent network requests, banner behavior (presence and prominence of reject button), Consent Mode signals, cookie declarations, and policy links. Run scans after any changes to maintain compliance.

What are common Next.js cookie compliance Spain cookie consent implementation and testing guide mistakes? Common mistakes include: loading tracking scripts before consent, missing or hidden reject button, incorrect Consent Mode defaults, embedding trackers in SSR output, and failing to rescan after updates. GDPRChecker can catch all these issues.

Which cookies and trackers should I check for Next.js cookie compliance Spain cookie consent implementation and testing guide? Check all non-essential cookies and trackers: analytics (Google Analytics, Matomo), marketing (Facebook Pixel, Google Ads), social media widgets, and any third-party embeds. GDPRChecker’s cookie inventory will list all detected cookies and classify them.

How often should I review Next.js cookie compliance Spain cookie consent implementation and testing guide? Review whenever you add new scripts, update your CMP, or change your privacy policy. Additionally, schedule monthly scans with GDPRChecker to catch any unintended changes. The AEPD expects ongoing compliance, not a one-time fix.

What evidence should I keep for Next.js cookie compliance Spain cookie consent implementation and testing guide? Keep records of consent choices (timestamps, preferences), CMP configuration snapshots, cookie policy versions, and GDPRChecker scan reports. These demonstrate accountability and can be crucial if the AEPD investigates.

Conclusion

Achieving Next.js cookie compliance in Spain requires a blend of careful implementation and continuous verification. By following the steps in this guide—choosing a robust CMP, integrating Consent Mode v2, conditionally loading scripts, and rigorously testing with GDPRChecker—you can build a consent framework that respects user privacy and meets regulatory expectations. Remember, compliance is not a one-time task; it’s an ongoing process of monitoring and improvement.

**Ready to verify your Next.js site?** Run a free scan with GDPRChecker now to detect pre-consent requests, banner issues, and disclosure gaps. For deeper integrations, explore our Google Analytics GDPR compliance guide and GDPR checklist for small businesses.

Implementation checklist

  1. Identify the pages, banners, tags, and vendors affected by the change.
  2. Record the current configuration and policy version before making changes.
  3. Define denied consent defaults before optional tags are allowed to run.
  4. Test Reject all, Analytics only where offered, and Accept all in a clean browser session.
  5. Check browser network activity for requests that fire before consent.
  6. Confirm that the cookie disclosure and privacy notice match the live configuration.
  7. Save the scan result, screenshots, and deployment reference as evidence.
  8. Schedule a follow-up scan after future script, banner, or policy changes.

Next step

Run a GDPRChecker scan to validate consent behavior, trackers, and disclosures after you implement the checklist above.

Article schema

```json { "@context": "https://schema.org", "@type": "Article", "headline": "Next.js Cookie Compliance in Spain: Cookie Consent Implementation and Testing Guide", "description": "Practical guide to Next.js cookie compliance in Spain. Step-by-step consent implementation, testing with GDPRChecker, and avoiding common mistakes. Ensure your Next.js site meets Spanish and GDPR requirements.", "mainEntityOfPage": { "@type": "WebPage", "@id": "https://www.gdprchecker.online/guides/next-js-cookie-compliance-in-spain-cookie-consent-implementation-and-testing-gui" }, "publisher": { "@type": "Organization", "name": "GDPRChecker", "url": "https://www.gdprchecker.online" } } ```

GDPRChecker guides are educational resources and do not constitute legal advice. Use them to understand technical and operational privacy requirements, and consult qualified counsel for legal interpretation.

Check Your Website in Under 60 Seconds

  • No signup required
  • GDPR-focused checks
  • Cookie banner detection
  • Privacy policy verification