Consent Mode is a reliable and easy way to ensure no Google services can run without consent if they are implemented using Google Tag Manager or gtag. While implementation is very simple, it may not be very easy to see if everything is working is intended.
First off, it's important to note that only the following tags in Google Tag Manager support "advanced Mode" (have Built-In Consent Checks):
Third party tags currently only support "basic mode" and require Additional Consent configuration.
To determine if Consent Mode is doing what it's supposed to, you need to check that:
- The Consent Mode default settings are registered in Google Tag Manager, and updated settings are pushed to the dataLayer when consent choices are made known.
- No cookies are set prior consent or after an opt-out.
We will go through these checks which help you determine if Consent Mode is implemented correctly and is working as intended.
We assume that you've added the Consent Mode script before the Google Tag Manager script or that you use the Usercentrics CMP tag from the Template Gallery.
1. Checking the Consent Mode settings
When a page loads prior consent, the Consent Mode settings should be correctly registered in Google Tag Manager.
Here is a script that allows you to check what consent settings are registered in Google Tag Manager:
(() => { l = s => s == undefined ? "" : s ? "granted" : "denied"; c = s => s == "granted" ? "color: #0C0": "color: #C00"; if (!"google_tag_data" in window) { console.log("No Consent Mode data found"); return; } var g = google_tag_data.ics.entries,
i = "", t = "",
u = ""; for (var a in g) { i = l(g[a]['initial']); u = l(g[a]['update']); if (i == "" && u == "") continue; t = ("\t" + a + ":" + (i != "" ? "\n\t\tDefault: %c" + i : "%c") + "%c" + (u != "" ? "\n\t\tUpdate: %c" + u : "%c")); console.log(t, i != "" ? c(i) : "", "", u != "" ? c(u) : "", ""); } if (i == "") console.log("No default Consent settings found"); })()
If you've added the Consent Mode script inline, you should see these settings in the dataLayer, before anything else.
Checking the contents of the dataLayer can be done by simply executing the command dataLayer
in the console, or using this script to make it a bit easier to read:
(function(w, d, t) { for (i of w[d]) t += JSON.stringify(i).replaceAll(/\"\d{1,}\":/g, "") + "\n"; console.log(t); })(window, "dataLayer", "")
The output should look similar to this:
{"consent","default",{"ad_storage":"denied","analytics_storage":"denied","wait_for_update":500}}
{"set","ads_data_redaction",true}
{"gtm.start":1608107133821,"event":"gtm.js","gtm.uniqueEventId":2}
{"event":"gtm.dom","gtm.uniqueEventId":3}
{"event":"gtm.load","gtm.uniqueEventId":5}
After consent has been given for all types of cookies, the dataLayer will contain both the initial, and updated Consent Mode settings:
{"consent","default",{"ad_storage":"denied","analytics_storage":"denied","wait_for_update":500}}
{"set","ads_data_redaction",true}
{"gtm.start":1608106162221,"event":"gtm.js","gtm.uniqueEventId":2}
{"event":"cookie_consent_preferences","gtm.uniqueEventId":3}
{"event":"cookie_consent_statistics","gtm.uniqueEventId":4}
{"event":"cookie_consent_marketing","gtm.uniqueEventId":5}
{"gtm.start":1608106162636,"event":"gtm.js","gtm.uniqueEventId":7}
{"event":"gtm.dom","gtm.uniqueEventId":9}
{"event":"gtm.load","gtm.uniqueEventId":11}
{"set","developer_id.dMWZhNz",true}
{"consent","update",{"ad_storage":"granted","analytics_storage":"granted"}}
{"set","ads_data_redaction",false}
2. Checking if cookies were set
This is the trickiest part. To make sure there aren't already any cookies set, or dragged along from a different domain, we need to make sure that no cookies were set previously.
You can ensure this by browsing in incognito mode, or by manually clearing cookies on the Application → Cookies tab in the Developer tools (F12 or Ctrl + Shift + i).
Without submitting consent, browse around a bit. Visit some pages, and click some links. Before accepting cookies, you shouldn't be seeing the _ga, _gid, or _gat cookies getting set.
If the last two checks were in order, it will be highly unlikely that you will see these cookies getting set prior consent. If they are, then you are likely adding them through an inline script, like analytics.js (which doesn't support Consent Mode).
"That's great, but my data doesn't look right."
So you've taken the steps above, and everything seems to be doing what it should, but you're not seeing the data you'd expect.
We get quite a few questions regarding this issue and unfortunately we can't help you in this regard.
Google Consent Mode is essentially an API which Usercentrics uses to pass consent data to Google Tag Manager. How a tag is supposed to respond to this data is beyond our purview.
We can, and will be happy to check if you've correctly set things up in regards to Usercentrics sending, and Google Tag Manager receiving consent settings. However, we have no insight in what tags do with these settings.
We can't comment on how Google Analytics should behave when it receives the Consent Mode instructions, or speak on Google's behalf in regards to what data should be logged.
This may seem dismissive, but there's nothing we can do on our end to improve the data logging in Google Analytics. The Usercentrics and Consent Mode scripts merely respectively set and update the consent state to Google Tag Manager. For more information on Consent Mode and the behavior of tags, you can check Google's own documentation on Consent Mode.
Comments
0 comments
Please sign in to leave a comment.