Shopify’s built-in cookie banner never talks to Google Tag Manager. If your GTM lives in theme.liquid, you need a small bridge script, or Consent Mode will never receive a default or an update.
I learned this on a Shopify store selling to customers in Germany. The owner had switched on Shopify’s native cookie banner, ticked “EU” in the privacy settings, and assumed the job was done. GA4 and Google Ads were running through GTM.
Then I opened GTM Preview. The banner showed up, I clicked Decline, and the Consent tab didn’t change at all. No default, no update, nothing. I clicked Accept in a fresh session: same thing. GA4 tags were firing on every page either way, with no consent signal attached.
Nothing was broken in the usual sense. Shopify was saving the visitor’s choice perfectly. It just wasn’t telling anyone outside Shopify about it.
Why it happens: two consent systems that never meet
Shopify and Google each keep their own record of consent, and nothing connects the two by default.
- Shopify’s side. The native banner stores the choice through the Customer Privacy API. Shopify’s own pixels and apps read it, and so does the Google & YouTube app for the tags it installs.
- Google’s side. GTM and gtag only understand Google Consent Mode:
gtag('consent', 'default', …)andgtag('consent', 'update', …)commands in the dataLayer.
When you paste GTM into theme.liquid yourself, it sits outside Shopify’s consent system. The banner can be working perfectly while GTM sees no consent state at all, which is exactly what Preview shows.
The good news is that the Customer Privacy API gives us everything we need to connect them:
analyticsProcessingAllowed(),marketingAllowed()andpreferencesProcessingAllowed()return true or false for each purpose.- A document event,
visitorConsentCollected, fires every time the visitor makes or changes a choice.
So the fix is a translator: read Shopify’s answer, then send it to Consent Mode.
The fix: a bridge script in theme.liquid
Paste this in theme.liquid directly after the opening <head> tag, above your GTM container snippet. The order matters: the default has to exist before GTM starts.
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
// 1) Default: everything denied before any tag loads
gtag('consent', 'default', {
ad_storage: 'denied',
analytics_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
functionality_storage: 'denied',
personalization_storage: 'denied',
security_storage: 'granted',
wait_for_update: 500
});
// 2) Translate Shopify's consent into Consent Mode
function pushShopifyConsent(source) {
var cp = window.Shopify && window.Shopify.customerPrivacy;
if (!cp) return;
var analytics = cp.analyticsProcessingAllowed();
var marketing = cp.marketingAllowed();
var prefs = cp.preferencesProcessingAllowed();
gtag('consent', 'update', {
analytics_storage: analytics ? 'granted' : 'denied',
ad_storage: marketing ? 'granted' : 'denied',
ad_user_data: marketing ? 'granted' : 'denied',
ad_personalization: marketing ? 'granted' : 'denied',
functionality_storage: prefs ? 'granted' : 'denied',
personalization_storage: prefs ? 'granted' : 'denied'
});
dataLayer.push({
event: 'shopify_consent_update',
consent_source: source,
consent_analytics: analytics,
consent_marketing: marketing,
consent_preferences: prefs
});
}
// 3) Load the API, apply any stored choice, then listen for changes
(function waitForShopify() {
if (!window.Shopify || !window.Shopify.loadFeatures) return setTimeout(waitForShopify, 50);
window.Shopify.loadFeatures(
[{ name: 'consent-tracking-api', version: '0.1' }],
function (err) { if (!err) pushShopifyConsent('page_load'); }
);
})();
document.addEventListener('visitorConsentCollected', function () {
pushShopifyConsent('banner_click');
});
</script>
<!-- Google Tag Manager snippet goes here -->
The script does three things:
- Sets a denied default for all four Consent Mode v2 signals before GTM loads.
wait_for_update: 500gives Shopify half a second to report a stored choice before tags decide what to do. - Reads Shopify’s answer on every page load. Returning visitors who accepted last week get their “granted” update straight away, so you don’t lose their data.
- Listens for the banner click and sends a fresh update the moment the visitor chooses.
I map Shopify’s marketing permission to all three ad signals, analytics to analytics_storage, and preferences to the functionality and personalization signals. That matches how most stores describe these categories in their cookie policy. If yours is different, change the mapping to match.
The extra shopify_consent_update event is optional but useful. You can use it as a trigger for tags that should only fire after a choice, and it makes debugging in Preview much easier.
How to test it in GTM Preview
A correct setup shows denied on Consent Initialization and a separate update the moment the visitor chooses. Test both paths in clean sessions:
- Open the store through GTM Preview in a private window, using an EU VPN (see the first mistake below).
- Click the Consent Initialization event and open the Consent tab. All four signals (
ad_storage,analytics_storage,ad_user_data,ad_personalization) should show Denied as the default. - Click Accept in the Shopify banner. A
shopify_consent_updateevent should appear, and the Consent tab should now show Granted under “On-page Update”. - Reload the page. The update should fire straight away with
consent_source: page_load, because Shopify remembers the choice. - Close everything, open a new private window, and repeat with Decline. The signals must stay Denied.
- Check the hits themselves. In the Network tab, filter for
collectand look at thegcsparameter on GA4 requests:G111means granted,G100means denied.
If step 2 shows nothing at all, the script is below GTM or isn’t on that template. If step 3 shows nothing, the visitorConsentCollected listener isn’t running. Check the browser console for errors.
Mistakes I see again and again
1. Testing from outside the region. Shopify only shows the banner in the regions you selected, and everywhere else it allows all processing by default. Test from Bangladesh, India or the US and you’ll see an instant “granted” update with no banner. It looks broken, but it’s working as configured. Use an EU VPN, or briefly turn the banner on for all regions while you test.
2. Putting GTM in a Custom Pixel and expecting Preview to work. GTM inside Settings → Customer events runs in a sandboxed iframe. Preview can’t connect properly, and the theme.liquid script above has no effect there. Inside a pixel you read the starting state from init.customerPrivacy and listen with api.customerPrivacy.subscribe('visitorConsentCollected', …) instead.
3. Setting the pixel’s permission to “Required”. Shopify only loads a custom pixel once the visitor has granted every permission it’s set to require. GTM then never loads before consent, so you never see a denied state, and Consent Mode’s cookieless pings never happen. If you want Consent Mode to do the gating, set the pixel to “Not required” and let the consent signals control the tags.
4. Sending consent from two places. The Google & YouTube app can send its own Consent Mode signals. If you also run this script, you’ll see two updates in Preview. That’s fine only if they agree. Never add a second hard-coded gtag('consent', 'update') anywhere else in the theme.
5. Forgetting the tags themselves. Consent signals only matter if the tags respect them. Google tags handle Consent Mode natively. Meta, TikTok, Pinterest and similar tags need Additional consent checks in GTM (for example, require ad_storage) or a trigger based on shopify_consent_update. Otherwise they fire whatever the visitor chose.
6. Placing the script below GTM. If the default loads after the container, early tags can fire with no consent state. Keep the script as the very first thing in <head>.
The takeaway
Shopify’s banner isn’t broken. It simply speaks Shopify’s language, and GTM speaks Google’s. One script in theme.liquid translates between them, and on that German store it took the setup from “tags firing regardless” to a clean denied default and a proper update on every choice.
Three checks before you call it done:
- Denied default on Consent Initialization, tested from inside the EU.
- A
shopify_consent_updateevent with the right values after both Accept and Decline. - Non-Google tags gated on consent, not just Google’s.
