How to Implement Google Consent Mode with Termageddon + Code Snippets

✂️ Code Snippets and Termageddon have partnered up to provide you step-by-step instructions on how to set up compatibility with Google Consent Mode 🍪

This step-by-step video (accompanied with the written instructions below) will help you learn:
  1. What Google Consent Mode is;
  2. The steps needed to set up compatibility with Google Consent Mode;
  3. The difference between Advanced vs Basic consent mode;
  4. How to test for proper implementation.

What is Termageddon?

Termageddon is an attorney founded website policies and consent solution platform that helps website owners keep their policies up to date with newly required disclosures as privacy laws change. As new laws go into effect, Termageddon notifies you by email and even has the ability to push newly required disclosures automatically to your policy pages, helping you avoid privacy related fines and lawsuits.

Their solution is $119 per year for a full set of policies (plus a cookie consent tool) to help protect one website. That includes a Privacy Policy, Cookie Policy, Terms, Disclaimer, consent banner, and more.

Special offer For Code Snippets users:

  1. If you own and manage your own websites, Termageddon is offering a discount for all new purchases for Code Snippets users.
  2. If you provide web design services to multiple customers, you can apply to be an agency partner to receive a complimentary license for your own website, as well as reseller/affiliate access in case you decide to ever recommend Termageddon to clients. Clients get protected, you make more recurring revenue, win win!

You do not need to use Termageddon to set up compatibility with Google Consent Mode; any properly built consent solution will suffice, and instructions will be very similar in nature to what is being shared with you in this article. We encourage you to research providers and select one who provides step-by-step instructions along with quality support, to ensure you get everything properly implemented.

Step-by-step Video Guide:

What’s happening? What is Google Consent Mode?

If you’re utilizing Google Tag Manager to fire multiple scripts, chances are you have been notified by Google that you need to set up compatibility with their new Consent Mode. If you haven’t received this notice, it is likely only a matter of time.

Due to privacy laws such as the Digital Markets Act, companies like Google, Facebook and Microsoft are now required to ensure their own users adhere to consent related privacy laws. This means if you are using products like Google Tag Manager, you may be required to set up compatibility with Consent Mode, otherwise Google may be penalized with a heavy fine.

Consent Mode is Google’s way of passing granular consent choices from a consent banner into Google Tag Manager, so that Google knows which tags to fire based on user consent choices.
To put this in an example, let’s say you are utilizing Google Tag Manager (GTM) to load two tags onto a website, Google Analytics 4 and Hotjar. When a user visits your website and consents to Google Analytics 4, but clicks ‘deny’ for Hotjar, that data needs to be passed into GTM so that Google knows to fire the Google Analytics 4 tag, but keep the Hotjar tag paused/off. This in a nutshell is why Google Consent Mode exists, and the remainder of this article outlines how to implement compatibility with this new Google feature.

Prerequisites

The overall approach to updating your consent tool to be compatible with consent mode is similar in nature for all Google certified CMP partners. In this example, we will show how to make these updates using Termageddon (and its 3rd party partner Usercentrics CMP) along with Code Snippets.
You will need access to:
  1. Your WordPress website (with the Code Snippets plugin installed/activated)
  2. Your Termageddon license (with the consent solution activated)
  3. Your Google Tag Manager account (with the regular GTM script added to the <head> of your website)
Please note this is documentation to set up compatibility with Google Consent Mode. This is not how to set up with the TCF framework.

Stage 1: Replace GTM script with new Consent Mode Script

Remove the original Google Tag Manager script from the <head> of your website:

				
					<script> (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,’script','dataLayer','GTM-XXXXXX');</script>
				
			

Replace it with Google’s Consent Mode Script:

In your /wp-admin area of your website, go to Tools -> Termageddon + Usercentrics and then paste the code below in the Additional Scripts area:

				
					<script type="text/javascript">
  window.dataLayer = window.dataLayer || [];
  function gtag() {
    dataLayer.push(arguments);
  }
  gtag("consent", "default", {
    ad_user_data: "denied",
    ad_personalization: "denied",
    ad_storage: "denied",
    analytics_storage: "denied",
    wait_for_update: 500
  });
  gtag("set", "ads_data_redaction", true);

  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window, document, 'script', 'dataLayer', 'GTM-XXXXXX');
</script>

				
			

Don’t forget to replace GTM-XXXXX with the correct ID

Do not change the body tag (pasted below for convenience):

				
					<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

				
			

Stage 2: Enable Consent Mode within Termageddon questionnaire, mark GTM as Essential

  1. Log into Termageddon: policies.termageddon.com
  2. Click into your license
  3. Click “Edit” for the Cookie Policy and Consent Tool
  4. Click ‘Enable’ for Google Consent Mode. 
  5. Click ‘Google Tag Manager | Edit’ -> Under General, change the Category to Essential
    1. Run a sitemap scan if not already. Also you can add services manually via “Add Service” -> “Pre-Defined”.

Stage 3: Decide on advanced vs basic for Google related Tags

When loading Google related tags through GTM (such as Google Analytics, Google Ads, Conversion Linker, etc), you have the option to use “Advanced” or “Basic” consent mode.

To put it simply: Basic = most privacy friendly, less data collection, more steps you have to take Advanced = not as privacy friendly, more data collection, less steps you have to take

Advanced Consent Mode only works for Google related products such as Google Analytics and Google Ads. Advanced is where Google utilizes cookieless pings to collect more data about the page interactions of a website visitor, without actually tracking that visitor using cookies. This is explained in more detail in the video.
Advanced does not work for custom scripts or third party scripts such as HotJar or Microsoft Clarity. For all non-Google products, you have to set up Basic Consent Mode.
Basic consent mode requires GTM users to set up a variable and a trigger, and update each tag to this new trigger. These tags will now only fire after explicit consent has been captured by the website visitor.
You can also set up Basic Consent Mode for your Google related tags. This means these tags will not fire at all until after consent is captured. Basic is considered a best privacy practice, however the website owner will receive less data regarding their website visitors’ interactions with the website.

The following Google Services currently support the Advanced Consent Mode:

Service

Consent Type

Conversion Linker

ad_storage

Display & Video 360

ad_storage

Google Ads

ad_storage

Google Ads Conversion Tracking

ad_storage

Google Ads Remarketing

ad_storage

Google Analytics

analytics_storage

Google Analytics 4

analytics_storage

Google Campaign Manager 360

ad_storage

Search Ads 360

ad_storage

Doubleclick Ad 

ad_storage

DoubleClick Floodlight

ad_storage

Google Campaign Manager

ad_storage

NEXT STEPS

If your Google Tag Manager account is only firing Google related tags (GA4, Google Ads, etc.), and you are wanting to utilize Google’s Advanced option for more data collection, then no further action is required (however we recommend you still test to confirm all is working properly).
However if you are using GTM to fire any non-Google related tags (and/or you are firing Google related tags but want to get explicit consent first), you must continue to the following Stages to set up Basic Consent Mode.

Stage 4: Set up Basic consent mode for all other (non Google related) Tags

  1. Navigate to Variables in the side-menu and then click on New.
  2. Name your variable. In this example, we will name it Google Analytics 4 Variable
  3. Add a new variable of type “Data Layer Variable“.
  4. Under Data Layer Variable Name, insert Google Analytics 4.
    ⚠️ Note: Correct spelling, hyphenation and capitalization are mandatory for this field. Every technology must be added the way it is spelled in the Usercentrics Admin Interface. Here: “Google Analytics 4”.
  5. Click/enable Set Default Value and type in false
  6. Click Save

You have now set up the Google Analytics 4 variable. Repeat this process for any other Google Services you use, outlined in the tables above.

Set up a Trigger
For this example, we will now set up a Trigger for Google Analytics 4. You will want to repeat this process for each Google Service you utilize within Google Tag Manager (see tables above).
⚠️ Note: There are several ways to implement this logic. Usercentrics recommends the following option, however, depending on your setup, other structures might be more reasonable.
  1. Navigate to Triggers in the side-menu and click on New
  2. Add a title to your trigger. For this example, we will type in “Google Analytics 4 Trigger”
  3. Click Trigger Configuration and select Custom Event
  4. Click/enable Use regex matching
  5. Under Event Name, paste in (consent_status.*)
    ⚠️ Note: Correct spelling, hyphenation and capitalization are mandatory for this field.
  6. Click/enable Some Custom Events
  7. In the drop-down menus, set the following condition: “Google Analytics 4 Variable” contains true.
    ⚠️ Explanation: The variable contains the user’s consent information (variable=true – user opted in || variable=false – user opted out) for a specific technology. Hence, the trigger should only be fired (and tag therefore activated), if the variable=true.
  8. Click Save
You have now set up the Google Analytics 4 trigger. Repeat this process for any other Services you use.

Add the Trigger to the respective Tag

  1. You can choose to pause your existing tags and create new ones, or you can modify your existing tags where you will remove the existing trigger and replace it with the new trigger. In this example, we will update an existing Tag. You can still utilize the steps below if you are creating new tags (just remember to pause any existing tags prior to testing in the final step).
  2. Navigate to Tags in the side-menu and click on your Google Analytics 4 tag
  3. Remove the preexisting trigger(s) and replace it with the newly created “Google Analytics 4 Trigger”
  4. Click Save
You have now set updated the Google Analytics 4 tag to fire only after a website visitor provides respectful consent. Repeat this process for any other Google Services you use, outlined in the tables above.

Stage 5: Testing

Test via the Preview Feature. Don’t forget to clear out all cookies and do a hard refresh after making any changes. Cookies should only load on the browser after consent is given.

Key items:
  1. Properly clear your browser cache when testing in preview mode. This is absolutely essential.
  2. Inspect the code of the website (via the Chrome browser) and go to “Applications” -> “Cookies” to see cookies load and confirm this only happens after consent is given.
The video above outlines in more detail proper methods to testing to help confirm you’ve successfully implemented Google Consent Mode.
Share this Post on Social
Facebook
Twitter
LinkedIn
Email

Check these related posts

Snippet Conditions Public Beta

✂️ Snippet Conditions: Now in Public Beta! 🎉 Code Snippets is incredibly excited to announce that Snippet Conditions, one of the most requested features…

Stay in the loop! Join our newsletter!

Sign up for new content updates, Code Snippets tips and much more!