Shopify Google Consent Mode v2 is a JavaScript snippet you add to your Shopify theme that tells Google whether a visitor has given permission to track them. It works alongside your existing Google Analytics and Google Ads tags. Without it, you lose conversion data for users who have not yet accepted cookies. This guide shows you how to install it, configure it in Google Tag Manager, and verify it is working on your specific store.
Why is my Shopify store missing data after the consent update?
If you are seeing gaps in your Google Ads or Google Analytics reports, the cause is likely missing or broken Consent Mode v2. When a user visits your site without accepting cookies, the browser blocks the standard tracking scripts. Consent Mode v2 changes this by sending a "consent status" to Google before any cookies are set. If the status is "denied", Google records the interaction but with limited data. If the status is "granted", Google records full data. If you do not implement this, you are simply losing the data that the browser blocks. You are not penalized by Google, but you are blinding your own reporting.
The update to version 2 was mandatory for all EU and UK traffic. It added new consent parameters for "ad_storage", "ad_user_data", and "ad_personalization". Many older tutorials only cover the basic "analytics_storage" and "ad_storage". If you only set those two, you are not fully compliant with the current requirements. You need all four parameters configured correctly in your theme code.
Where to put the code in your Shopify theme
You must place the Consent Mode v2 snippet in the head section of your theme. It needs to load before any other Google tags. Shopify allows you to edit theme code directly, but you should make a backup first.
- Go to your Shopify admin.
- Click on "Online Store" and then "Themes".
- Find your live theme and click "Edit code".
- In the left sidebar, under "Layout", click on
theme.liquid. - Scroll to the very top of the file, inside the
<head>tag. - Paste the Consent Mode v2 snippet.
The snippet looks like this:
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'wait_for_update': 500
});
</script>
The wait_for_update parameter is critical. It tells the browser to wait 500 milliseconds for the user to interact with the cookie banner. If they click "Accept" within that window, the consent status updates to "granted" before the tags fire. If they do not, the tags fire with "denied" consent.
Do not hardcode "granted" in this default state. That defeats the purpose of consent management. The default must always be "denied" until the user actively accepts.
Configuring Google Tag Manager for Shopify
Most Shopify stores use Google Tag Manager (GTM) to manage their tags. If you install GTM via the Shopify app, the container code goes into the theme as well. However, the Consent Mode v2 snippet must be placed before the GTM container snippet in the theme.liquid file.
If your GTM container loads before the consent defaults are set, the tags will fire without knowing the consent status. This results in invalid data.
Inside GTM, you need to ensure your Google Analytics 4 (GA4) and Google Ads tags are configured to respect the consent state.
- Open your GTM workspace.
- Go to "Tags" and click on your GA4 Configuration Tag.
- In the "Consent" section, ensure "Wait for Consent" is checked.
- Do not set specific consent values in the tag itself. The values come from the
dataLayerpush in your theme code. - Repeat this for your Google Ads Conversion Tag.
If you are using the Google Ads Linker tag, it also respects the consent state. You do not need to change the tag logic. You just need the default consent values in the page head.
A common mistake is adding the consent code inside the GTM container itself. This does not work reliably because the container loads asynchronously. The consent defaults must be in the raw HTML head, before the container script executes.
Testing if Google Consent Mode v2 is working
You cannot trust that it is working just because you added the code. You must verify the data flow.
First, check your browser console. Open your Shopify store in Chrome. Press F12 to open DevTools. Go to the "Console" tab. Type the following command and press Enter:
dataLayer
You should see an object. Look for the gtag('consent', 'default', ...) push. If you see the four parameters with "denied" values, the code is loading.
Next, you need to test the "granted" state. Click your cookie banner "Accept" button. Then type dataLayer in the console again. You should see a new push with the values changed to "granted".
To verify Google is receiving the data, use the Consent Mode checker. It scans your site and tells you if the four required parameters are present and set to the correct default values. If it reports missing parameters, your code is not firing correctly.
For deeper verification, use the Google Tag Assistant browser extension. Install it from the Chrome Web Store. Click the extension icon. It will show you the tags firing. Look for the "Consent" section in the tag details. It should show "Denied" initially. After you accept cookies, refresh the page. It should show "Granted".
If Tag Assistant shows "Unknown" consent, your code is not in the right place. Move it higher in the <head> tag.
Handling the cookie banner on Shopify
Shopify does not have a built-in cookie banner that integrates natively with Consent Mode v2. You need a third-party app or custom code.
Popular apps include Pandectes, Cookiebot, and iubenda. These apps inject their own banner and consent logic. However, they do not always send the correct gtag('consent', 'update', ...) command to the dataLayer.
If you use an app, you must check its documentation. Does it support Consent Mode v2? Many apps added support after the update. If the app does not send the update command, you must add custom code to your theme to bridge the gap.
Here is a simple example of how to send the update when the user accepts:
// Add this to your theme.js or a custom script
document.querySelector('#accept-cookies').addEventListener('click', function() {
gtag('consent', 'update', {
'analytics_storage': 'granted',
'ad_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted'
});
});
Replace #accept-cookies with the actual ID or class of your banner's accept button. You can find this in your browser's DevTools.
If you use a custom-built banner, ensure it sends the update command for all four parameters. Sending only "ad_storage" is not enough.
Common errors and how to fix them
Error 1: Consent Mode v2 not detected by Google
This usually means the code is loading after the tags. Move the snippet to the very top of the <head> tag. Ensure it is before the GTM container script.
Error 2: Data still missing after acceptance Check your GA4 and Google Ads tags in GTM. Ensure "Wait for Consent" is enabled. If it is disabled, the tags fire immediately, ignoring the consent state.
Error 3: Banner does not update consent
Your banner app or custom code is not sending the gtag('consent', 'update', ...) command. Check the browser console after clicking "Accept". If you do not see the update push, the code is not running.
Error 4: Mixed content warnings If your site is on HTTPS, ensure all scripts are loaded over HTTPS. Consent Mode v2 does not use external domains, so this is rare, but check for any other tags that might be causing issues.
Error 5: Multiple consent defaults
If you have two snippets in your head, the second one overrides the first. Remove duplicates. Only one gtag('consent', 'default', ...) call should exist.
Verifying data in Google Analytics 4
After implementing Consent Mode v2, wait 24 to 48 hours for data to populate. Go to your GA4 property.
Navigate to "Reports" > "Acquisition" > "Traffic Acquisition". Look at the "Sessions" and "Users" metrics. You should see data from users who accepted cookies.
To see the impact of consent, go to "Admin" > "Data Streams" > "Web Stream". Click on the stream. You will see a "Consent" section. It shows the number of users who gave consent and those who did not.
If you see zero consented users, your code is not working. If you see 100% consented users, your default is set to "granted" incorrectly.
For Google Ads, go to "Conversions" > "Conversions". Look at the "Imported" conversions. You should see conversions from users who accepted cookies. Users who denied consent will not have conversions imported, but their click data is still recorded in a limited form.
Advanced: Server-side tracking for better accuracy
Client-side tracking, even with Consent Mode v2, is vulnerable to browser extensions and ad blockers. Many users have ad blockers that prevent the gtag function from running entirely. This means your consent code never fires, and you lose data even from users who would have accepted.
Server-side tracking solves this by moving the tag logic to your server. The user's browser sends a request to your server, and your server sends the data to Google. This bypasses most ad blockers and provides more accurate data.
If you are running a high-value Shopify store, server-side tracking is worth considering. It requires more setup but provides more reliable data. You can learn more about server-side tracking for Shopify if you want to explore this option.
For now, ensure your client-side Consent Mode v2 is working correctly. It is the baseline requirement. Without it, you are non-compliant. With it, you are compliant and capturing data from consenting users.
Final checklist
Before you close this guide, run through this list:
- Backup of your theme code created.
- Consent Mode v2 snippet added to
theme.liquidhead. - Snippet is before the GTM container code.
- All four parameters set to "denied" by default.
-
wait_for_updateset to 500 or higher. - GTM tags have "Wait for Consent" enabled.
- Cookie banner sends
gtag('consent', 'update', ...)on accept. - Browser console shows correct
dataLayerpushes. - Google Tag Assistant shows correct consent state.
- GA4 reports show consented users.
If you pass this checklist, your Shopify Google Consent Mode v2 setup is complete. You are compliant with Google's requirements. You are capturing data from users who give permission. You are no longer losing conversion data due to cookie blocks.
Keep an eye on your reports for the next few days. If you see a sudden drop in data, check your code again. Browsers update frequently, and sometimes a theme update can break the snippet. Regular monitoring is part of the job.
For more guides on tracking and compliance, check out our blog for the latest updates on Shopify and Google tools. If you need help with your setup, you can contact us for a consultation.