Introduction
Updated for 2026 compliance practices.
Google Tag Manager React cookie consent is a practical compliance topic for website owners validating consent, tags, and disclosures. If you run a React application and use Google Tag Manager (GTM) to deploy analytics, advertising, or other tracking scripts, you must ensure that these tags respect user consent choices under the GDPR. This guide walks you through the technical implementation steps, common pitfalls, and how to verify your setup using GDPRChecker’s scanner. We focus on actionable steps for developers and site owners, not legal advice. By the end, you’ll have a clear path to close the consent gap in your React app.
Requirements and Compliance Expectations
Under the GDPR, you must obtain valid consent before processing personal data via cookies or similar technologies, unless the processing is strictly necessary. The European Data Protection Board (EDPB) provides guidance on what constitutes valid consent: it must be freely given, specific, informed, and unambiguous. See EDPB Guidelines 05/2020 on consent. For React apps using GTM, this translates into several technical requirements:
- Pre-consent blocking: Tags that set non-essential cookies must not fire until consent is granted. This includes analytics (e.g., Google Analytics 4), advertising (e.g., Google Ads), and social media pixels.
- Granular control: Users should be able to choose which categories of cookies they accept. Your implementation must allow GTM to fire only the tags corresponding to the consented categories.
- Consent revocation: Users must be able to easily withdraw consent at any time. When they do, all non-essential tags should stop firing, and previously set cookies should be removed where possible.
- Documentation: Your privacy policy must clearly disclose what tags are used, what data they collect, and how users can manage their preferences.
Google’s Consent Mode is a helpful framework for managing tag behavior based on consent. It allows you to adjust how Google tags (like GA4 and Google Ads) behave depending on the consent state, without completely blocking them. For example, with Consent Mode v2, you can send cookieless pings for analytics even when consent is denied, which helps with modeling. However, Consent Mode alone is not a full consent solution; you still need a CMP or custom banner to collect user choices. We’ll cover how to implement Consent Mode in React later.
Note that this guide provides technical implementation guidance, not legal advice. Consult with a legal professional to ensure your specific setup meets all regulatory requirements.
Common Mistakes and How to Avoid Them
Even with careful implementation, several mistakes can undermine your Google Tag Manager React cookie consent setup. Here are the most frequent ones and how to avoid them.
1. Tags Firing Before Consent
The most critical mistake is allowing tags to fire before the user has given consent. This often happens when GTM loads with default consent set to granted, or when tags are not configured to check consent state. To avoid this, always set default consent to denied for non-essential categories, and use GTM’s consent settings or custom triggers to block tags until consent is updated.
2. Ignoring React’s SPA Nature
In a React app, the GTM container might only load once, and subsequent page views don’t trigger the standard page view event. If you rely on GTM’s built-in page view trigger, you’ll miss tracking on route changes. Always push custom page view events on navigation, as shown in Step 6.
3. Not Handling Consent Revocation
Users must be able to change their mind. If your banner only appears once and there’s no way to reopen it, you’re not compliant. Provide a persistent link or button (e.g., “Cookie Settings”) that allows users to update their preferences. When they do, push the new consent state to GTM and, if possible, delete previously set cookies.
4. Incomplete Cookie Deletion on Revocation
When a user revokes consent, you should delete any cookies that were set based on that consent. This can be challenging because cookies might be set by third-party scripts. You can use JavaScript to delete cookies on your domain, but for third-party cookies, you may need to rely on the browser’s mechanisms or instruct users to clear them. At minimum, ensure that no further data is collected after revocation.
5. Overlooking Consent Mode Implementation
If you use Google services like GA4 or Google Ads, implementing Consent Mode is highly recommended. Without it, you lose all data from users who deny consent. Consent Mode allows you to send cookieless pings, which can be used for modeling in GA4. However, Consent Mode must be correctly configured with the default and updated consent states. A common mistake is setting the default to granted, which defeats the purpose. Always start with denied and update after user interaction.
6. Not Testing with a Scanner
Manual testing can miss issues like hidden tags or third-party requests. Use a scanner like GDPRChecker to automatically detect cookies, trackers, and consent violations. We’ll discuss this in the next section.
How to Validate with GDPRChecker
After implementing Google Tag Manager React cookie consent, you need to verify that your setup works correctly. GDPRChecker’s scanner can help you identify pre-consent network requests, banner behavior, and disclosure gaps. Here’s how to use it:
- Run a scan: Enter your website URL into GDPRChecker and start a scan. The scanner will crawl your site and analyze cookies, trackers, and consent mechanisms.
- Check pre-consent requests: Look for any network requests to third-party domains (like Google Analytics or Facebook) that occur before consent is given. These should be blocked. If you see them, review your GTM trigger conditions and default consent state.
- Verify banner behavior: Ensure that the scanner detects your consent banner and that it correctly blocks tags until the user interacts. Test both accept and reject flows.
- Review cookie categorization: The scanner will list all cookies found. Verify that they are correctly categorized (e.g., analytics cookies are not mislabeled as essential).
- Check for disclosure gaps: Your privacy policy should list all cookies and trackers in use. GDPRChecker can compare the scan results with your policy to find discrepancies.
Regularly scan your site, especially after making changes to GTM or your React app. This helps you catch new tags that might slip through without consent checks. For a deeper dive into consent verification, see our guide on Google Consent Mode v2 Checker.
Implementation Checklist
Use this checklist to ensure your Google Tag Manager React cookie consent implementation is complete and compliant.
- Load GTM with default consent set to denied for all non-essential categories.
- Implement a consent banner that appears on first visit and stores user choice in localStorage.
- Provide options to accept all, reject all, and customize preferences.
- Push updated consent state to GTM data layer when user makes a choice.
- On app initialization, read saved consent from localStorage and push to GTM.
- Configure all GTM tags to require appropriate consent before firing.
- Implement Consent Mode for Google tags (GA4, Google Ads) with correct default and update behavior.
- Push custom page view events on React Router navigation.
- Provide a persistent link to reopen consent preferences (e.g., “Cookie Settings”).
- Handle consent revocation by updating GTM state and deleting cookies where possible.
- Test all consent flows manually using GTM preview mode and browser dev tools.
- Run a GDPRChecker scan to detect pre-consent requests, banner issues, and disclosure gaps.
For more on related topics, check out our guides on Google Analytics GDPR Compliance and Cookie Banner Requirements.
FAQ
What is Google Tag Manager React cookie consent?
Google Tag Manager React cookie consent is the practice of controlling GTM tags in a React application based on user cookie preferences. It ensures that tracking scripts only fire after the user has given valid consent, as required by GDPR. This involves integrating a consent banner with GTM’s consent APIs and configuring tags to respect the consent state.
Do I need Google Tag Manager React cookie consent for GDPR?
Yes, if your React app uses GTM to deploy non-essential cookies (e.g., analytics, marketing), you must obtain prior consent under GDPR. Without a consent mechanism, you risk non-compliance and potential fines. Even if you don’t run Google Ads, you may still need consent for analytics cookies; see our guide on Do I Need a CMP If I Do Not Run Google Ads.
How do I implement Google Tag Manager React cookie consent?
Implement by: (1) setting GTM default consent to denied, (2) building a consent banner that stores user choice, (3) pushing consent updates to GTM’s data layer, (4) configuring tags in GTM to require consent, and (5) handling React SPA navigation with custom page view events. Use Consent Mode for Google services. Test thoroughly with GTM preview and a scanner.
How can I verify Google Tag Manager React cookie consent with a scanner?
Use GDPRChecker to scan your site. It will identify pre-consent network requests, check if your banner blocks tags correctly, and list all cookies. Verify that no non-essential tags fire before consent, and that your privacy policy matches the scan results. Regular scans help maintain compliance after updates.
What are common Google Tag Manager React cookie consent mistakes?
Common mistakes include: tags firing before consent due to incorrect default state, not handling SPA page views, lacking a consent revocation mechanism, incomplete cookie deletion on revocation, misconfiguring Consent Mode, and failing to test with a scanner. Avoid these by following the step-by-step guide and using the implementation checklist.
Ready to ensure your React app’s GTM setup is compliant? Run a scan with GDPRChecker today to identify and close any consent gaps.
Copyright and editorial notice
© GDPRChecker
This original AI-assisted editorial draft was selected, reviewed, and published by GDPRChecker. All rights are reserved where protected by applicable law. Do not reproduce the article without permission.