How To Implement GA4 Consent Mode V2 on Shopify

Author: Jacob Gardner-Shortall - Junior Developer

Date: 23 February 2024

Google’s Consent Mode V2 Deadline for Advertisers

With the deadline of Google’s Consent Mode V2 rapidly approaching, advertisers may lose out on performance if this is not implemented by 1st March 2024. It will now be required to capture users' consent if you use Google services for collecting data to build audience and remarketing lists. Consent Mode V2’s update means you will be required to capture consent for the parameters ad_user_data and ad_personalization. 

Google has provided the developer document for a fully custom integration but we wanted to create a quicker and simpler guide to understand what consent mode could mean for you and the steps you need to take if you’re using Shopify. This will require knowledge of Shopify, Google Ads and Google Tag Manager.

What App Should I Use to Implement Consent Mode?

What’s available?

The type of app you’re looking for is called a Consent Management Platform, or CMP for short. CMPs come with different levels of features and prices, so it can be tricky to choose the one that’s best for your business. The best place to start is Google’s CMP Partner Program, where you can see all of the CMPs that are officially integrated with Google Tag Manager and Google Consent Mode, offering the most seamless installation and maintenance.

Amongst this list of official partners you’ll find integrations for many types of web platforms, ranging from WordPress to Shopify, to custom built solutions. Feel free to take a look through each CMP, but we’ve already done the dirty work and have detailed our preferred solution below that is guaranteed to integrate with Shopify.

What’s our preferred solution and why?

After looking through the list of CMP partners and their capabilities, we found CookieYes to be the most effective solution. All of the options require some level of manual setup to get up and running, but we found CookieYes to handle a larger portion of this setup automatically when compared with alternatives with some of them requiring full custom development. 

CookieYes offers multiple payment tiers, but even the free option (allowing up to 25,000 page views per month) includes everything you need for managing Consent Mode V2, unlike some of the alternatives. All tiers also have solid customisation options, with the higher plans offering greater design freedom. Overall, CookieYes offers the most flexibility and competitive pricing across plans.

How Do I Set Up CookieYes on a Shopify Store?

Now, let’s go through getting CookieYes up and running on your Shopify store so you can start collecting user consent. Some of the steps in this guide may require the assistance of a developer.

  1. Install the CookieYes plugin from the Shopify app marketplace.
  2. Once installed, sign up/log in to be taken to the app dashboard. This is a 3rd-party dashboard handled outside of the Shopify admin.
  3. After logging in, you’ll be prompted to copy two scripts to set up the plugin. If you forgot to copy them, simply go back to the web app dashboard and in the top left panel and select get installation code. Copy the scripts you are given.
Screenshot of a Cookie banner status live on a Shopify website.
  1. Before exiting the web app dashboard, check that Google Consent Mode is enabled. Do this by clicking Advanced settings in the top navigation bar and selecting the following option at the bottom of the page:
Screenshot of Google consent mode being turned on on a website
  1. Once you have our CookieYes scripts, you need to place this and two other scripts into the <head> element of the website. The other two scripts are a custom Consent Mode script, which we will detail below, and your existing GTM/gtag script. These scripts must be arranged in a specific order for the integration to work. The order is as follows:
    • Custom consent mode script
    • GTM script
    • CookieYes Scripts
  2. Using the theme file editor or a local code editor, add the following custom consent mode script to the website <head> element first:
<script>
   window.dataLayer = window.dataLayer || [];
   function gtag() {
       dataLayer.push(arguments);
   }
   gtag("consent", "default", {
       ad_storage: "denied",
       ad_user_data: "denied",
       ad_personalization: "denied",
       analytics_storage: "denied",
       functionality_storage: "denied",
       personalization_storage: "denied",
       security_storage: "granted",
       wait_for_update: 2000,
   });
   gtag("set", "ads_data_redaction", true);
   gtag("set", "url_passthrough", true);
</script>
  1. Next, add your GTM script and your CookieYes scripts below, in that order. It’s crucial that the order is correct for the integration to load correctly. Once set up, CookieYes will automatically prevent analytics and marketing cookies until the user gives the correct consent.

How Do I Set-up Google Tag Manager to Manage Consent On My Google Tags?

Now that you’ve got CookieYes ready to go on your Shopify store, it’s time to test the integration using Google Tag Manager.

  1. To test the implementation, create a custom tag in Tag Manager. Start by creating a new tag.
  2. For this example, select Custom HTML as the tag type. Add in the following into the HTML field:
<script>console.log('Testing Consent Mode')</script>
  1. Under Advanced Settings > Consent settings, select Require additional consent as seen below. We are requiring the ad_storage value to be granted in this example, but you can choose a different value from the custom Consent Mode script from the previous section.
Screenshot showing Advanced Settings options in Google Tag Manager
  1. For the trigger, create a custom event using the event name: cookie_consent_update. This should fire on All Custom Events. Using this event name means that the custom HTML will only fire when a user grants consent for ad_storage.
Screenshot of Trigger Configuration setup on Google Tag Manager

This is only a basic example, but hopefully one that demonstrates how you can block or allow actions in Google Tag Manager based on the type of tracking consent a user gives on your website. 

Summary

Google Consent Mode is coming in March 2024, and failing to adhere to these new guidelines will lead to Google blocking you from collecting EEA user data, negatively affecting GA4 and Google Ads.

It is vital that any business utilising these services ensures their marketing is in line with these new regulations. If you require any assistance with Google Consent Mode, or any other digital project, please don’t hesitate to get in touch.

Wonder Agency Lightbulb

Let us help you with that idea

Wonder what we can do for you? Send us a message and we’ll let you know!

Let's Talk