why is my cookie banner blocking google analytics on shopify

Your cookie banner is blocking Google Analytics on Shopify because your tags fire before visitors give consent. Fix your tag sequencing to capture missing data.

Eptekhar Hasan8 min read
Illustration for why is my cookie banner blocking google analytics on shopify

Your cookie banner is blocking Google Analytics on Shopify because your tracking tags fire before the consent signal updates. When a visitor clicks accept, Google Analytics is already stuck in a denied state. You fix this by changing your tag sequence so GA4 waits for the consent update before loading.

The reason your cookie banner is blocking Google Analytics on Shopify comes down to timing. Most store owners install a consent app, switch on Google Consent Mode v2, and assume the software handles the rest. The software does not. Your Shopify store loads Google Analytics the moment a visitor arrives. The consent banner loads a second later. Because the visitor has not accepted cookies yet, Google Consent Mode sets your analytics storage to denied. The visitor clicks accept, but Google Analytics has already fired. It does not fire again, and you lose the session data entirely.

The tag firing sequence is backward

When you install a consent banner, it communicates with Google Analytics through Google Consent Mode v2. This system uses two states for analytics storage: granted and denied.

Your GA4 tag likely fires on page load. At that exact millisecond, the visitor has not clicked anything. The consent state defaults to denied. The tag fires, reads the denied state, and sends a cookieless ping instead of a normal session. A second later, the visitor clicks accept. The banner updates the consent state to granted. But your GA4 tag has already finished its work.

You can check your current tag sequence using a consent mode checker to see exactly which signals your store sends before and after a click. This tells you if your default states are configured correctly.

Shopify handles consent asynchronously. When a page loads, the Shopify privacy object takes a moment to initialise. If your tracking scripts load faster than this object, they read an unknown consent state. When a visitor clicks accept, Shopify fires a specific event called visitorConsentCollected. Your tracking setup must listen for this exact event.

Google Consent Mode v2 operates in two different ways. These are basic consent mode and advanced consent mode. Basic consent mode strictly blocks all Google tags until the visitor clicks accept. No cookieless pings are sent. Advanced consent mode allows Google tags to fire immediately but restricts them to cookieless pings until consent is granted. If you use basic consent mode, your tags must be completely blocked by your consent app. If you use advanced consent mode, your tags fire but send restricted data. You must decide which version your store uses before you change your tag triggers.

To fix this timing issue, you must change your tag triggers. If you use Google Tag Manager, open your workspace. Find your GA4 configuration tag. Change the trigger from All Pages to a custom event that fires on a consent update. This forces Google Analytics to wait for the visitor to make a choice.

This timing issue does not only affect Google Analytics. If you run Facebook ads, your Meta Pixel suffers from the exact same problem. The Meta Pixel fires on page load, reads a denied state, and drops the session. When you fix your tag triggers for Google Analytics, you must apply the identical fix to your Meta Pixel tags. Both platforms require the visitorConsentCollected event to fire before they can track a fully consented session.

You hardcoded Google Analytics into your theme

Many store owners paste their GA4 snippet directly into their theme files. You might have added the code to your header file months ago. This breaks your consent setup immediately.

Shopify uses a system called the Customer Privacy API. When a visitor clicks accept on your banner, the banner writes that decision into the API. Every official Shopify tool reads that API and respects the choice.

A script pasted into your theme code never reads that API. The browser finds the script in the HTML and runs it immediately. The cookie banner has no mechanical way to stop a script that is already executing. As explained in a detailed breakdown of Shopify theme scripts, the built in banner only controls Shopify managed surfaces like Custom Pixels and checkout.

You need to remove the hardcoded script.

  1. Open your Shopify admin panel.
  2. Click Online Store and select Themes.
  3. Click the three dots next to your active theme and select Edit code.
  4. Open the theme.liquid file.
  5. Find the Google Analytics script containing gtag and delete it.
  6. Save the file.

Once the code is gone, install the official Google and YouTube app from the Shopify app store. This app connects directly to the Customer Privacy API. It holds Google Analytics back until the API confirms the visitor has granted consent.

Shopify introduced Custom Pixels to solve this hardcoding problem. You find them in your admin panel under Settings and Customer Events. A Custom Pixel runs in a secure sandbox environment. It automatically reads the Customer Privacy API. If you must use custom tracking scripts, you should place them inside a Custom Pixel instead of your theme code. When you paste a script into a Custom Pixel, Shopify wraps it in consent logic. If the visitor has not accepted cookies, Shopify prevents the sandbox from executing the script. This protects you from compliance failures.

Not all cookie banners talk to Shopify natively. If you installed a third party consent app, it might be operating in isolation. The app shows a banner and records the click. But if it does not push that click into the Shopify Customer Privacy API, your store still thinks the visitor has not consented. GA4 remains blocked.

You must map your consent app to Shopify. Open your Shopify admin and navigate to Settings. Click Customer Privacy. Look for the consent banner section. If Shopify tells you the built in banner is active alongside your third party app, you have a conflict. Turn off the Shopify banner.

Open your consent app settings. Look for an integration tab. You need to enable the setting that syncs the app with Shopify consent. This setting pushes the granted or denied status directly into the API. When the API updates, the official Google app reads the change and fires GA4.

Google Consent Mode v2 requires four specific signals. These are ad_storage, analytics_storage, ad_user_data, and ad_personalization. Your consent app must update all four signals when a visitor clicks accept. If your app only updates analytics_storage, your Google Ads remarketing lists will fail to populate. Some consent apps require you to upgrade to premium pricing models to access granular consent logs and full v2 support.

You need to prove your banner actually blocks and unblocks Google Analytics. You cannot test this by simply looking at your live analytics dashboard. You must inspect the network requests in your browser.

Follow these exact steps to test your setup.

  1. Open an incognito window in Chrome.
  2. Right click anywhere on the page and select Inspect.
  3. Click the Network tab in the developer tools panel.
  4. Type collect into the filter box.
  5. Load your Shopify store URL.
  6. Look at the network panel before you touch the cookie banner.

If you see a request to Google Analytics before you click accept, your banner is failing. Your tags are firing without consent.

Now click accept on the banner. You should see a new network request appear in the panel. Click on that request. Scroll down to the query string parameters. Look for the parameter named gcs. This parameter carries your Google Consent Mode status. If the value is G111, your consent update worked. Google Analytics is now tracking the session legally.

Google Consent Mode v2 introduced a new parameter called gcd. This parameter is a long string of letters and numbers. It encodes the exact sequence of consent updates. It tells Google whether the consent was granted by default, or updated after a click. You must check the gcd parameter in your network tab. If the string contains the letter l for your analytics storage, it means the signal was denied and never updated. If it contains the letter r or v, it means the signal was granted.

If no request appears after you click accept, your tag sequence is broken. You need to implement a consent update trigger. If you are tired of fixing broken browser tags, you can bypass these frontend issues entirely by moving to server side tracking for a more resilient setup.

Location rules are hiding your data

Shopify enforces strict privacy rules based on the visitor location. If you test your store from a region with strict laws, Shopify blocks tracking by default.

In the United Kingdom and the European Union, visitors must opt in. The analytics storage state is denied until the user clicks accept. If you are testing from London, you will see GA4 blocked.

In the United States, visitors operate under an opt out model. The analytics storage state is granted by default. The banner might show a link to opt out, but tracking happens immediately.

Store owners often confuse this expected behaviour with a broken setup. You might ask a developer in a different country to check your banner. They load the site, see GA4 firing immediately, and tell you the banner is broken. They are simply testing from an opt out region.

You can verify this by using a VPN. Set your location to Germany. Load your store in an incognito window. Check the network tab. GA4 should be blocked. Change your location to California. Load the store again. GA4 should fire immediately. This confirms your location rules are working as intended.

Missing data from ad blockers and browser privacy

Even with a perfect consent setup, you will still lose data. Many visitors click accept on your banner, but Google Analytics still fails to record their session.

This happens because the visitor uses an ad blocker or a privacy focused browser. Brave and Safari block Google Analytics natively. Chrome extensions like uBlock Origin stop tracking scripts from loading entirely.

Your cookie banner has no control over this. The visitor grants consent, the banner updates the API, and Shopify tells GA4 to fire. But the browser intercepts the request and kills it.

You cannot fix this in your theme or your consent app. If a browser refuses to load the Google Analytics script, the frontend session is lost. You can read more about how browser restrictions impact your marketing in our recent work with local businesses. We often find store owners chasing consent banner fixes when their real problem is browser level blocking. If you need help diagnosing whether your missing data comes from a broken banner or browser restrictions, you can contact us for a technical review.

Keep reading

All guides