GDPRChecker

Home / Knowledge Base / React Consent Mode v2 Setup Guide: Practical Steps for GDPR Compliance

Website Compliance

React Consent Mode v2 Setup Guide: Practical Steps for GDPR Compliance

A practical guide for implementing Google Consent Mode v2 in React applications, covering step-by-step setup, common mistakes, and validation with GDPRChecker scanner to ensure GDPR compliance.

Run a free GDPR compliance scanPreview the findings before choosing a CMP.

Author

GDPRChecker Editorial Team

Reviewed by

Privacy & Compliance Research Team

Last updated

July 2026

Reading time

11 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.

For website owners using React, implementing Google Consent Mode v2 is a critical step toward aligning with GDPR requirements for user consent. This React consent mode v2 setup guide provides a practical, technical walkthrough to help you configure consent signals correctly, avoid common pitfalls, and verify your implementation using GDPRChecker’s scanning tools. While this guide focuses on the technical aspects, it does not constitute legal advice; you should consult with a qualified privacy professional to ensure full compliance with applicable regulations.

Google Consent Mode v2 introduces two new consent signals—ad_user_data and ad_personalization—in addition to the existing analytics_storage and ad_storage. These signals allow you to control how Google tags behave based on user consent choices, enabling a more granular approach to data collection. In a React application, integrating Consent Mode requires careful handling of state management, tag loading, and banner interactions. This guide will walk you through the entire process, from understanding the requirements to validating your setup with GDPRChecker.

Requirements and Compliance Expectations

Before diving into the code, it’s essential to understand the compliance landscape. Under GDPR, consent must be freely given, specific, informed, and unambiguous. This means your React application must present a cookie banner or consent widget that clearly explains what data is collected and for what purposes, and it must allow users to make granular choices. Google Consent Mode v2 does not replace a CMP; rather, it works alongside it to translate user choices into signals that Google tags understand.

Key requirements include: - Prior consent: No Google tags that set cookies or collect personal data should fire before the user has made a choice, unless they are configured to behave in a consent-aware manner (e.g., using Consent Mode’s default state). - Granular control: Users must be able to accept or reject specific purposes, such as analytics or advertising. Your React state must reflect these choices accurately. - Respect for withdrawal: Users must be able to change their consent preferences at any time, and your app must update the consent signals accordingly. - Documentation: You should maintain records of consent, which is typically handled by your CMP, but your technical implementation must support this.

From a technical standpoint, Google requires that Consent Mode v2 be implemented for continued use of certain advertising features in the European Economic Area (EEA). The official Google documentation (see Google Consent Mode) outlines the necessary signals and default behaviors. Additionally, the European Data Protection Board (EDPB) provides guidance on valid consent mechanisms, and resources like GDPR.eu offer overviews of the regulation.

Common Mistakes and How to Avoid Them

Even experienced developers can make mistakes when implementing React consent mode v2. Here are some of the most common pitfalls and how to steer clear of them.

Mistake 1: Loading Tags Before Default Consent

If your Google tags load before the default consent script, they may fire with full data collection capabilities, ignoring the consent state. To avoid this, place the default consent script as high as possible in the <head>, and ensure that your React app does not load any Google scripts until after that script has executed. In a React context, this often means using a synchronous script tag in the HTML template rather than dynamically injecting it via JavaScript.

Mistake 2: Not Handling Reject-Flow Properly

Many implementations focus on the “Accept All” path but neglect the “Reject All” or granular rejection flows. When a user rejects all, you must update the consent state to 'denied' for all signals. Failure to do so can result in continued data collection, which is a serious compliance gap. Test the reject flow thoroughly, and ensure that your CMP correctly communicates the denied state to your React app.

Mistake 3: Ignoring SPA Navigation

In a traditional multi-page website, each page load triggers a fresh consent check. In a React SPA, you must manually reapply consent on route changes. If you forget to do this, Google tags might revert to default behavior or lose the consent state. Implement a route change listener that re-sends the consent update or reconfigures tags.

Mistake 4: Overlooking wait_for_update

The wait_for_update parameter is crucial for asynchronous CMPs. If you set it too low, tags might fire before the user’s choice is registered. If you set it too high, you may delay tag loading unnecessarily. A value between 300 and 500 milliseconds is typically sufficient, but you should test with your specific CMP’s load time.

Mistake 5: Relying Solely on Client-Side State

Consent preferences should be persisted in a way that survives page refreshes and browser restarts. Using only React state without localStorage or a cookie means that if the user refreshes the page, they might see the banner again or lose their settings. Always sync consent to persistent storage and rehydrate on app initialization.

How to Validate with GDPRChecker

After implementing React consent mode v2, validation is essential to ensure that your setup works as intended and that no compliance gaps remain. GDPRChecker scans help verify pre-consent network requests, banner behavior, and disclosure gaps after changes. Here’s how to use GDPRChecker to validate your implementation:

  1. Run a Pre-Consent Scan: Use GDPRChecker to scan your React site before any consent is given. The scanner will check for network requests to third-party domains, including Google, and flag any that occur before consent. This helps you confirm that your default consent state is effectively blocking data collection.
  2. Test Consent Interactions: Interact with your consent banner (accept all, reject all, granular choices) and run scans after each action. GDPRChecker will verify that the appropriate consent signals are being sent and that tag behavior changes accordingly.
  3. Check for Disclosure Gaps: The scanner can identify missing or incomplete disclosures in your cookie banner or privacy policy. Ensure that your banner clearly lists all purposes and that your privacy policy is up to date.
  4. Validate Across Pages: Since React is an SPA, run scans on multiple routes to ensure that consent state persists and that no new, unexpected requests appear on navigation.
  5. Schedule Regular Scans: Compliance is not a one-time task. Set up recurring scans with GDPRChecker to catch any regressions after updates to your app, CMP, or Google tags.

For a deeper dive into related topics, see our guides on Google Analytics GDPR compliance and the Google Consent Mode v2 guide. If you’re unsure whether you need a CMP, read Do I need a CMP if I do not run Google Ads?.

Implementation Checklist

Use this checklist to ensure your React consent mode v2 setup is complete and compliant:

  1. Default consent state set to 'denied' for all signals in the HTML <head>.
  2. Google tags (gtag.js or GTM) loaded only after default consent script.
  3. CMP integrated and configured to fire consent update callbacks.
  4. React state synchronized with CMP consent choices.
  5. Consent update function calls gtag('consent', 'update', {...}) with correct values.
  6. Consent preferences persisted in localStorage or a cookie.
  7. On app initialization, rehydrate consent state from storage and reapply.
  8. Route change listener re-sends consent update or reconfigures tags.
  9. Reject-all flow tested and verified to set all signals to 'denied'.
  10. Granular consent choices (e.g., only analytics) correctly reflected in signals.
  11. Pre-consent network requests verified with GDPRChecker scan.
  12. Cookie banner and privacy policy disclosures reviewed for completeness.

FAQ

What is React consent mode v2 setup guide?

React consent mode v2 setup guide is a practical compliance topic for website owners validating consent, tags, and disclosures. It provides step-by-step instructions for integrating Google Consent Mode v2 into a React application, ensuring that user consent choices are respected by Google tags.

Do I need React consent mode v2 setup guide for GDPR?

If your React site uses Google services like Analytics or Ads and targets users in the EEA, implementing Consent Mode v2 is a key technical measure for GDPR compliance. This guide helps you configure it correctly to avoid unauthorized data collection.

How do I implement React consent mode v2 setup guide?

Implementation involves setting default consent states, conditionally loading Google tags, updating consent on user action, and handling SPA navigation. Detailed steps are provided in this guide, along with code examples and common pitfalls.

How can I verify React consent mode v2 setup guide with a scanner?

GDPRChecker scans can verify your setup by checking pre-consent network requests, banner behavior, and disclosure gaps. Run scans before and after consent interactions to ensure tags behave as expected.

What are common React consent mode v2 setup guide mistakes?

Common mistakes include loading tags before default consent, neglecting reject-flow testing, ignoring SPA navigation state, misconfiguring wait_for_update, and failing to persist consent. This guide explains how to avoid each.

Conclusion

Implementing React consent mode v2 is a nuanced but essential task for GDPR compliance. By following this React consent mode v2 setup guide, you can ensure that your React application correctly communicates user consent to Google services, minimizing the risk of non-compliance. Remember to validate your implementation with GDPRChecker’s scanning tools to catch any gaps. For further reading, explore our guides on Consent Mode v2 vs Google Certified CMP, the Google Consent Mode v2 checker, and cookie banner requirements. Start your scan today at GDPRChecker to close the consent mode gap and build a more privacy-respecting website.

Next step

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

This guide is technical implementation guidance for website owners. It is not legal advice.

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

  • Sign in required
  • GDPR-focused checks
  • Cookie banner detection
  • Privacy policy verification