How to Disable Google Analytics Cookies
Controlling website cookies is no longer just a technical task, it's a fundamental part of respecting user privacy and complying with global regulations. If you're using Google Analytics, managing its cookies is something you need to handle correctly. This guide will walk you through exactly what Google Analytics cookies do and how to disable them based on user consent, using modern, best-practice methods.
What Are Google Analytics Cookies and Why Would You Disable Them?
Google Analytics relies on small text files called cookies, which are placed in a user's browser, to function. These first-party cookies help it distinguish one user from another and remember their actions across sessions. They are the mechanism that allows GA to report on metrics like user counts, session duration, and returning visitors.
The primary reasons for disabling or controlling these cookies are rooted in privacy and legal compliance:
- GDPR, CCPA, and More: Privacy laws like the General Data Protection Regulation (GDPR) in Europe and the California Consumer Privacy Act (CCPA) require that you get explicit consent from visitors before placing non-essential cookies (like those for analytics) on their device. If a user says no, you must respect that choice.
- User Trust: Being transparent about data collection and giving users control builds trust. When visitors see a clear cookie banner and know their preferences are respected, it creates a more positive perception of your brand.
- Privacy-Forward Technology: The digital landscape is shifting towards a "cookieless future." Learning to operate without relying entirely on cookies now prepares your analytics strategy for what's next.
Disabling these cookies doesn't mean you have to stop using Google Analytics. Instead, it means implementing a system that fires them conditionally based on user choice.
The Main GA4 Cookies You Need to Know
Google Analytics 4 uses a couple of main client-side cookies to collect data. Understanding their jobs makes it easier to grasp why managing them matters.
- _ga: This is the primary cookie. It's used to distinguish unique users. It gets a randomly generated Client ID assigned to it, which helps Google Analytics recognize a returning visitor. By default, it lasts for two years.
- ga[container-id]: This newer cookie is used to persist session state. For example, it helps GA understand how many pages a user visited within a single session.
In the past with Universal Analytics, you might have also seen cookies like _gid (to distinguish users) and _gat (to throttle request rate), but GA4 has streamlined the process with the two cookies listed above.
The Best Method: Implementing Google Consent Mode V2
The most effective and Google-recommended way to manage GA cookies isn't to simply block them cold. Instead, you should use Google Consent Mode. This is an API that adjusts the behavior of your Google tags based on the consent status of your users, which they signal through a cookie banner or widget.
Here’s how it works:
- A user lands on your site and is greeted by your Consent Management Platform (CMP) banner (e.g., Cookiebot, OneTrust, CookieYes).
- The user makes their choice: they can accept all, reject all, or choose specific cookie categories.
- Consent Mode "listens" to that choice.
If the user consents to analytics cookies (analytics_storage is granted), the Google tags function normally, setting cookies to measure user behavior in detail.
If the user denies consent (analytics_storage is denied), Google tags will not read or write analytics cookies. Instead, GA4 will receive cookieless "pings." These are anonymous data signals that allow Google to model your traffic and conversions to help fill the data gaps from users who opted out. You get aggregated, privacy-safe insights without violating user consent.
This is the best of both worlds: you stay compliant, respect user privacy, and still get valuable modeled data in your GA4 reports.
Step-by-Step: Enabling Consent Mode for GA4 with Google Tag Manager
Google Tag Manager (GTM) is the easiest way to manage your tags and implement Consent Mode. If you have your GA4 tag installed via GTM, follow these high-level steps.
1. Enable Consent Overview in GTM
First, you need to turn on the consent management features in your GTM container.
- Navigate to your GTM container and click on Admin.
- Under the Container settings, click Container Settings.
- In the Additional Settings section, check the box for Enable consent overview.
- Save your changes. You'll now see a small shield icon on your Tags overview page.
2. Set Default Consent States
Right away, you need to tell your Google tags what to do before a user has made a choice. The most privacy-conscious approach is to deny everything by default.
- In GTM, go to the Tags section and create a new tag.
- Choose the tag type Consent Mode. You might need to search for it in the Community Template Gallery and add it to your workspace.
- Under Default Consent State, click Add Setting.
- Set
analytics_storageto Denied. You should also setad_storageto Denied for a default-deny setup. - For the trigger, choose the Consent Initialization - All Pages trigger. This special trigger is designed to fire before any other tags, ensuring the default consent is set immediately.
- Name your tag (e.g., "Consent Mode - Default") and save it.
**Important:** The *Consent Initialization* trigger is specifically built for setting default consent. Do not use a regular Page View trigger, as it may fire too late.
3. Configure Your Google Tag's Consent Settings
Next, you need to make sure your actual GA4 tag is aware of the consent settings.
- Go to your existing Google Tag (the one that sends data to GA4).
- Open the tag configuration and expand the Advanced Settings section.
- Go to Consent Settings.
- The setting "Not Set" is usually fine, as GTM will automatically check for consent. However, for clarity, you can check Built-In Consent Checks and ensure
analytics_storageis listed. This tells the tag, "Before you fire, you need permission foranalytics_storage." - Save the tag. Now, this tag will only set cookies if consent for
analytics_storageis "granted."
4. Connect Your Consent Management Platform (CMP)
This is the final piece of the puzzle. Your CMP is what collects user choices and communicates them to Consent Mode. Most major CMP providers (Cookiebot, OneTrust, etc.) have direct integrations with an official GTM tag template.
The general workflow is:
- You install your CMP's JavaScript snippet directly on your site as recommended in their documentation.
- Inside GTM, you add your CMP's tag template.
- This tag will handle sending the
updatecommand to Consent Mode when a user interacts with the banner. For example, if a user clicks "Accept All," the CMP tag fires a command likegtag('consent', 'update', { 'analytics_storage': 'granted', 'ad_storage': 'granted' }).
Once the update command is received, any Google tags that were blocked will now be permitted to fire on subsequent page loads or actions, and these tags will now be able to set their cookies.
Alternative Method: Disabling Cookies with the gtag.js Snippet
If you don’t use Google Tag Manager and have placed the gtag.js Universal Google Analytics snippet directly on your site, you can still implement Consent Mode. You’ll need to add a command to the snippet to set the default consent state.
The code must be placed before any code that sends data to Google (like gtag('config', 'G-XXXXXXXXXX'),).
Here is how you would modify your snippet to deny consent by default:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-YOUR_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [],
function gtag(){dataLayer.push(arguments),}
// Set default consent state for all storage types to 'denied'
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'wait_for_update': 500
}),
gtag('js', new Date()),
gtag('config', 'G-YOUR_MEASUREMENT_ID'),
</script>With this configuration, the Google Analytics cookies will not be set on page load. You will then need to build a mechanism (usually by hooking into the buttons of your cookie banner) to call the update command when a user gives their consent:
// This function would be called when a user clicks 'Accept'
function updateUserConsent() {
gtag('consent', 'update', {
'analytics_storage': 'granted'
}),
}Final Thoughts
Effectively disabling Google Analytics cookies comes down to respecting user choice through a well-implemented consent framework. Using Google Consent Mode with Google Tag Manager is the most robust, compliant, and feature-rich method available today, allowing you to honor user privacy while still getting valuable (and modeled) insights.
As you work on tag management and compliance code, it is sometimes easy to lose sight of the bigger picture: analyzing the data itself. At Graphed, we help you bridge that gap. After connecting sources like Google Analytics, we enable you to instantly build dashboards and ask questions about your data using a simple, natural language chat. It removes the friction of reporting so you can focus on getting clear answers, not just wrestling with technical setups.
Related Articles
How to Connect Facebook to Google Data Studio: The Complete Guide for 2026
Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.
Appsflyer vs Mixpanel: Complete 2026 Comparison Guide
The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?