Journal · Consent Mode

How to set up Google Consent Mode v2 on Shopify

2 September 20267 min readBy Walter Masseroni Gonzalez, Leon Aves, Daragh McCarthy and Alana Rossi

Set Consent Mode defaults to denied in theme.liquid above your container, then have your banner write each choice to Consent Mode and to Shopify's Customer Privacy API on the same click. If your Google tags come only from the Google & YouTube app, Shopify's banner or a CMP connected to that API sets Consent Mode for you.

Shopify's Customer Privacy API governs what the platform controls: Custom Pixels and app pixels. Nothing you do in Google Tag Manager reaches it. It listens for one thing, Shopify.customerPrivacy.setTrackingConsent(), and until something calls that, it holds whatever state it already had. Shopify documents the method in its Customer Privacy API reference.

Google Consent Mode v2 governs your own tags: the container in theme.liquid and everything it fires. It listens for gtag('consent', ...) and has no idea the Customer Privacy API exists.

So there are two failure shapes. Wire only Consent Mode and your GA4 and Ads tags behave while Custom Pixels and app pixels carry on unblocked. Wire only the Shopify side and your own container fires ungated.

One banner click has to write to both.

Shopify

Customer Privacy API

Governs Custom Pixels and app pixels, including the checkout pixel.

Written to by setTrackingConsent()

Google

Consent Mode v2

Governs the container in theme.liquid and the Google tags it fires: GA4 and Google Ads.

Written to by gtag('consent', 'update', ...)

Neither system reads the other, and neither one warns you that the other was never told.

The two consent systems a Shopify store runs. Most setups wire one of them and look finished, because nothing on either side reports that the other never heard about the visitor's choice.

Do Google tags from the Google & YouTube app need any of this?

Mostly not. Google's own consent mode setup guide says that once Shopify's cookie banner is active, consent mode is enabled automatically, and that the Google & YouTube app should work automatically when your CMP integrates with the Customer Privacy API. On that route there is one consent system your Google tags answer to, and it is Shopify's.

The rest of this guide is for the other route: GA4 or Google Ads tags in a Google Tag Manager container you placed in the theme, or a container loaded as a Custom Pixel. Shopify's customer privacy help says a custom web pixel needs a code snippet added by hand to activate Consent Mode v2. A store can run both routes at once, say the app for Ads conversions and a container for GA4, and then each tag follows a different system.

  • Google & YouTube app only: turn on Shopify's banner or a CMP that writes to the Customer Privacy API, then verify (step six).
  • Your own container, in the theme or a Custom Pixel: follow all six steps.
  • Both: follow all six steps, and check that the app's tags and the container's tags report the same state.
  1. Decide which banner owns the decision

    Shopify's own banner, under Settings then Customer privacy, or a CMP. Shopify's banner writes to the Customer Privacy API for you, which covers tags from the Google & YouTube app, but Shopify documents no Consent Mode update for a container you added to the theme, so you still bridge it to that container. A CMP installed as a Shopify app usually does both sides; one pasted into the theme as a script does the Google side only until you add the callback. Step six is what tells you which halves yours actually covers.

  2. Set denied defaults above the container

    A Consent Mode default command setting ad_storage, analytics_storage, ad_user_data and ad_personalization to denied, placed in theme.liquid before the container snippet, not after it. This is the ordering the whole setup rests on: a default that arrives after the container has already fired a tag is not a default, it is a correction that came too late. If you serve regions outside the EEA, scope the defaults by region rather than denying everywhere.

  3. Keep the banner in the theme, never in a Custom Pixel

    Custom Pixels run inside a sandboxed iframe with its own opaque origin. A banner cannot render into the page from there, and cookie writes from inside it do not behave like first party writes. The banner belongs in theme.liquid, in the main page context, above the container.

  4. Write the choice to both systems on the same click

    On accept or reject, send the Consent Mode update, and in the same handler call Shopify.customerPrivacy.setTrackingConsent() with the matching categories. If you skip this half, Custom Pixels and app pixels never learn the visitor said no. This is a gap we keep finding on Shopify stores that believe they are done.

  5. React to the choice in the same page view

    Shopify fires a visitorConsentCollected event when consent is recorded. Listen for it and apply the state rather than waiting for the next navigation, so a visitor who accepts on the collection page is measured on that page rather than from the next one onward.

  6. Verify on the live storefront, on both paths, and check out separately

    Not in preview. On the deny path your GA4 request should still leave with a gcs value showing denial rather than not leave at all, Custom Pixels should be absent, and no advertising cookies should be set. On the accept path all of it should appear. Tag Assistant shows the consent state each Google tag read. Then repeat the whole check inside checkout, which runs in its own sandbox and can behave differently from the storefront you just tested.

The ordering argument without the Shopify specifics is in why tags fire before the cookie banner loads. To see which one you ended up running, basic versus advanced Consent Mode is quicker than reading your own container.

What surprises people on Shopify?

Pending is not accepted. Before a visitor chooses, the Customer Privacy API reports a pending state. A bridge that treats anything other than an explicit no as a yes leaks on every first page view. Treat pending as denied.

Checkout is a different environment. Shopify's checkout runs pixels inside that sandboxed iframe, on an opaque origin where cookie writes throw. A setup that is perfect on the storefront can still produce checkout sessions carrying no page context.

What to check when the numbers still look wrong

Diagnose the two systems separately, because the symptom names the side that failed. Custom Pixels still firing after a rejection means the Customer Privacy API was never written to: step four. GA4 going silent rather than sending denied pings means your defaults deny without Consent Mode active at all: step two. Cookies before any click means something loads above your defaults, usually a hardcoded script rather than a container tag, which is a categorisation question.

Velo handles both halves from one decision. The banner sits in the theme and writes Consent Mode and the Customer Privacy API on the same click. It passes the same state into the container, so both systems work from the same record of what the visitor chose.

Common questions

How do I set up Google Consent Mode v2 on Shopify?

If your Google tags come from the Google & YouTube app, Shopify's banner or a CMP connected to the Customer Privacy API sets Consent Mode for you. For your own container, set the Consent Mode defaults to denied in theme.liquid above it, and load your banner in the theme rather than in a Custom Pixel. On the visitor's click, send both the Consent Mode update and a call to Shopify's setTrackingConsent. Shopify runs two consent systems: the Customer Privacy API governs Custom Pixels and app pixels, and Consent Mode governs the tags in your container. Writing to only one leaves the other firing on whatever state it already held. Then verify on the live storefront on both the accept and the deny path, and check out separately, because checkout runs in its own sandbox.

Does Shopify's own cookie banner support Google Consent Mode v2?

For tags installed through the Google & YouTube app, yes: Google's help says consent mode is enabled automatically once Shopify's banner is active. For tags in a container you added to the theme yourself, no. Shopify's banner writes the visitor's choice to the Customer Privacy API, which governs Custom Pixels and app pixels, and Shopify documents no Consent Mode update for your own container. You still need a bridge that listens for the consent decision and issues the gtag consent update, or a consent app that does both halves for you.

Why do my Shopify Custom Pixels still fire after a visitor rejects cookies?

Because Custom Pixels are governed by Shopify's Customer Privacy API, not by Google Consent Mode, and nothing has written a rejection to it. Consent Mode has no reach into the platform layer. Whatever collects the choice has to call setTrackingConsent with the matching categories on the same click that sends the Consent Mode update. Until it does, the platform holds whatever state it had, and pending is not a rejection.

Why does the cookie banner not appear for some returning visitors on Shopify?

On one store, we expanded a Shopify banner to the full set of European regions. Visitors who had browsed before the banner existed stayed grandfathered as accepted and were never shown it, while fresh visitors correctly got the pending state and the banner. That is one store's observed behaviour rather than a documented rule, so confirm it on yours. Where it holds, an accept rate measured in the first weeks after launch is mixing two populations.

Keep reading


Start with a scan

See what your homepage already loads before you install anything. The free scanner reads the page and your public Tag Manager container.


A first pass, not a verdict. Four checks on your homepage, and we open your container.
V
Free scanNo account needed

Free for one site and 1,500 monthly sessions. Pro from €7 a month, plus VAT, for unlimited sites.

Step by step installs for WordPress, Shopify, Webflow, Wix and more.

Free for one site

Banner, scan and consent records for one site, free. Pro from €7 a month, plus VAT, for unlimited sites.