{"id":3534,"date":"2024-08-28T10:31:49","date_gmt":"2024-08-28T10:31:49","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/how-to-set-up-google-consent-mode-v2-in-magento-2\/"},"modified":"2025-07-22T09:36:23","modified_gmt":"2025-07-22T04:06:23","slug":"how-to-set-up-google-consent-mode-v2-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/how-to-set-up-google-consent-mode-v2-in-magento-2\/","title":{"rendered":"How to Set Up Google Consent Mode v2 in Magento 2?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Not only users but also Google loves privacy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google has now made cookie consent mandatory for websites to collect users\u2019 data from the EEA region. Therefore, if you\u2019re selling to or have traffic from this region, you may need to implement it on your Magento 2 store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we cover how to set up Google Consent Mode v2 in Magento 2 and comply with Google\u2019s guidelines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"whatisgccm\">What is Google Cookie Consent Mode?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Google Cookie Consent Mode is a framework that allows you to collect user\u2019s permission to store cookies for advertising and marketing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To comply with the user\u2019s data privacy laws, Google has made Consent Mode v2 mandatory to offer a more transparent online experience.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As a marketer, your main benefit is that your Google tags and scripts start to operate in the privacy realms and your store complies with the privacy laws in regions like Europe and the UK.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google also plans to expand on it as much as possible in more countries and regions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"howdoeswork\">How Does Consent Mode Work via Google Tags?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Google Consent Mode V2 sends users\u2019 cookie preferences via Google Tags. This includes obtaining consent from users to use their data with services like Google ads.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some common consent types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ad_storage \u2013<\/strong>&nbsp;Enables storage (such as cookies) related to advertising<\/li>\n\n\n\n<li><strong>ad_user_data \u2013&nbsp;<\/strong>Sets consent for sending user data related to advertising to Google<\/li>\n\n\n\n<li><strong>ad_personalization \u2013&nbsp;<\/strong>Sets consent for personalized advertising<\/li>\n\n\n\n<li><strong>analytics_storage \u2013<\/strong>&nbsp;Enables storage (such as cookies) related to analytics e.g. visit duration<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Initially, the default state of cookie preferences is sent to Google via tags on page load. This state is updated when the users set or change the cookie preferences.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It can be implemented in two ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Basic&nbsp;<\/strong>\u2013 Tags are not loaded until users set their preferences. No data is sent to Google unless the user accepts the cookie consent.<\/li>\n\n\n\n<li><strong>Advanced<\/strong>&nbsp;\u2013 Tags are loaded on page load and cookieless pings are sent to Google unless the user accepts the cookie consent.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In a nutshell, Google cookie consent mode v2 is helpful to take permission from users to use their data for advertising and marketing purposes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"howtoimplement\">How to Implement Google Consent Mode v2 in Magento 2?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To install Google Consent Mode v2 or to <a href=\"https:\/\/meetanshi.com\/blog\/how-to-add-cookie-banner-to-magento-2\/\">add cookie banner to Magento 2<\/a>, you can add a custom script that stores user preferences and interacts with Google tags. This requires you to hire a professional developer to implement the logic and cookie consent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">One easier option is to use a ready-made&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-google-consent-mode.html\">Google Consent Mode v2 module for Magento 2<\/a>. It helps you comply with the privacy laws and streamline your data collection in your existing analytics (via GTM or gtag.js) setup.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s go through each step in detail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install\">Step 1: Install Magento 2 Consent Mode v2<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Magento-2-Google-Consent-Mode-V2.png\" alt=\"Magento 2 Consent Mode v2\" class=\"wp-image-55084\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Firstly,&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-google-consent-mode.html\">download the extension<\/a>&nbsp;zip file and extract it to your Magento root directory. Log into your SSH and run these commands step by step:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>php bin\/magento setup:upgrade<\/code><\/li>\n\n\n\n<li><code>php bin\/magento setup:static-content:deploy \u2013f<\/code><\/li>\n\n\n\n<li><code>php bin\/magento cache:flush<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Once done, the Google Consent Mode extension for Magento 2 will be successfully installed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"customize\">Step 2: Customize Cookie Banner<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to the Magento admin panel and head to&nbsp;<strong>Stores &gt; Configuration &gt; Meetanshi &gt; Cookie Consent v2<\/strong>&nbsp;to enable the extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, you can start customizing the cookie banner as per your preferences.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/General-Cookie-Settings.png\" alt=\"General\" class=\"wp-image-55086\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>General Cookie Setting<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cookie preferences button helps users to update their preferences any time after setting them. You can choose to show or hide this button and change its background color.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Cookie Notice Display Customization Settings<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the first site visit, the cookie notice is displayed to the users. You can customize this notice text, link, and set the expiration date for the preferences data.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Cookie-Notice-Display-Customization-Settings.png\" alt=\"Cookie Notice Display Customization Settings\" class=\"wp-image-55087\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You can also customize the labels and colors for the following buttons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Accept \u2013&nbsp;<\/strong>Sets all consent states to \u2018granted\u2019<\/li>\n\n\n\n<li><strong>Decline \u2013<\/strong>&nbsp;Sets all consent states to \u2018declined\u2019 except the essential ones<\/li>\n\n\n\n<li><strong>Set Custom Preferences \u2013&nbsp;<\/strong>Opens a cookie preference pop-up, allowing users to select their preferences<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Decline-Cookie-Except-Essential-Ones.png\" alt=\"Decline cookies\" class=\"wp-image-55089\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">For example, here\u2019s what the consent banner looks like with these settings:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Consent-Banner.png\" alt=\"\" class=\"wp-image-55090\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"edit\">Step 3: Edit Cookie Groups &amp; Consent Banner<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default, the extension comes with all the consent types required to collect data for Google\u2019s services like ads and analytics. These consent types are added to cookie groups, which customers can accept or deny.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can edit these consent types and cookie groups or create new ones.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go to&nbsp;<strong>Cookie Consent v2 &gt; Manage Cookie Groups<\/strong>&nbsp;to create or edit a cookie group. You can set the cookie group status (only enabled cookie groups are displayed on the front end.)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Set as Essential \u2013&nbsp;<\/strong>Enable this to make it compulsory (users can not deny)<\/li>\n\n\n\n<li><strong>Cookie Group Code \u2013&nbsp;<\/strong>Enter a code that is used as a reference (generally group name in small case)<\/li>\n\n\n\n<li><strong>Cookie Group Name \u2013&nbsp;<\/strong>Enter the name to be displayed on the cookie preferences pop-up<\/li>\n\n\n\n<li><strong>Description \u2013&nbsp;<\/strong>Enter a description for the cookie group<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">You can also control the position of the cookie group in the preferences pop-up through sort order.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Edit-Cookie-Group-and-consent-group.png\" alt=\"Settings\" class=\"wp-image-55091\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Click&nbsp;<strong>Save<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similarly, you can edit or create new consent types and add to cookie groups.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go to&nbsp;<strong>Cookie Consent v2 &gt; Manage Consent Parameters.&nbsp;<\/strong>Here, you can edit any existing one or create a new one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click the&nbsp;<strong>Add a New Consent Parameter<\/strong>&nbsp;button<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Manage-Consent-Parameters.png\" alt=\"Manage Consent Parameters\" class=\"wp-image-55092\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You can configure the following settings:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Parameter Code:&nbsp;<\/strong>Enter the consent code to send to Google tag<\/li>\n\n\n\n<li><strong>Default Status:&nbsp;<\/strong>Set the default status for the consent type<\/li>\n\n\n\n<li><strong>Cookie Group:&nbsp;<\/strong>Assign the consent to a particular cookie group<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/New-Consent-Parameter.png\" alt=\"New consent Parameter\" class=\"wp-image-55093\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">After you are done, click on the&nbsp;<strong>Save Parameter<\/strong>&nbsp;button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Magento 2 Consent Mode v2 in Action<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once the extension is configured, your Magento 2 store is ready and equipped with a fully working cookie consent mode v2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cookie consent notification banner is displayed when the users visit the site for the first time.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Magento-2-consent-mode-v2-in-action.png\" alt=\"Magento 2 Consent Mode v2 in Action\" class=\"wp-image-55094\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Based on the user preference, the cookie status will be updated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If they opt to choose a custom preference, they can select specific cookie groups from the available options. (These are the active cookie groups that are configured in the backend.)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Select-and-accept-cookie-group.png\" alt=\"cookie status\" class=\"wp-image-55095\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">After the users have selected their preference, the cookie consent will not appear till it has expired (the number of days you added in Step 1).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And, if configured, the cookie preferences button appears through which the users can modify their preferences.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Users-can-update-preferences.png\" alt=\"Consent Logs grid\" class=\"wp-image-55096\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You can track logs of the consent preferences set by customers in the&nbsp;<strong>Cookie Consent v2 &gt; Cookie Consent Logs grid<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2024\/08\/Cookie-Consent-Logs.png\" alt=\"Cookie consent log\" class=\"wp-image-55097\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><div class=\"meetanshi-cta\">\r\n<div class=\"cta-content-wrapper\">\r\n<span>Magento 2 Google Consent Mode v2<\/span>\r\n<p>Get customer insights while staying within the privacy boundaries.<\/p>\r\n<a href=\"https:\/\/meetanshi.com\/magento-2-google-consent-mode.html\" target=\"_blank\" class=\"btn-primary\">Get Now <\/a>\r\n<\/div>\r\n<div class=\"cta-image-new\">\r\n<img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2025\/11\/google-consent-mode-v2.png\" alt=\"Magento 2 Google Consent Mode v2\">\r\n<\/div>\r\n<\/div><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"howtocheck\">How to Check if Google Cookie Consent Mode is Working?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To check if the cookie consent in Magento 2 is working properly via GTM, follow these steps::<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to<a href=\"https:\/\/tagassistant.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;Open Tag Assistant<\/a>&nbsp;and enter your website URL.<\/li>\n\n\n\n<li>Test your banner and accept all cookies.<\/li>\n\n\n\n<li>Verify if the page sets the default consent correctly, and it updates the consent based on your interaction.<\/li>\n\n\n\n<li>If there are more tags on your website, check if they are working well as per the consent status.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"faqs\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">What Happens if I Don\u2019t Implement Consent Mode v2?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Failing to implement Consent Mode v2 will make a difference in the data you receive. No data will be captured and won\u2019t be personalized, leading to running generic ads that might not get you quality clicks.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I Run Google Ads Without Consent Mode in v2?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the EU and the UK, you must get cookie consent to use users\u2019 data in Google Ads and any other Google products. Google has made it mandatory since March 2024. However, you don\u2019t need it if your users are from other regions.<\/p>\n\n\n\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"What Happens if I Don\u2019t Implement Consent Mode v2?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Failing to implement Consent Mode v2 will make a difference in the data you receive. No data will be captured and won\u2019t be personalized, leading to running generic ads that might not get you quality clicks.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Can I Run Google Ads Without Consent Mode in v2?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"In the EU and the UK, you must get cookie consent to use users\u2019 data in Google Ads and any other Google products. Google has made it mandatory since March 2024. However, you don\u2019t need it if your users are from other regions.\"\n    }\n  }]\n}\n<\/script>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wn\">What\u2019s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now that Google has made Cookie Consent compulsory for the EU and the United Kingdom, it plans to make things mandatory for other countries like Singapore, Switzerland, and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As said before, Cookie consent doesn\u2019t look like a temporary fix for Google; they are leveraging it, and as a store owner, you must not miss out on doing so as you will miss out on your valuable user insights, which is a risk no one wants to take.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not only users but also Google loves privacy. Google has now made cookie consent mandatory for websites to collect users\u2019 data from the EEA region&#8230;.<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-3534","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/3534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=3534"}],"version-history":[{"count":5,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/3534\/revisions"}],"predecessor-version":[{"id":26323,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/3534\/revisions\/26323"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=3534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=3534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=3534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}