Can you believe there’s still Cookie Consent Managers around with GTM support, but no support for Consent Mode? Well.. I found one, and I fixed it. Read how below…
It required jumping through many, many hoops, so here’s my approach, hope it will help you.
This approach maybe applies to other consent managers as well, so read the first paragraph and you’ll see if it’s relevant.
How does Finsweet work?
The way finsweet works is using 1 dataLayer event per consent setting.
- event: “essential-activated”
- event: “analytics-activated”
- event: “marketing-activated”
- event: “personalization-activated”
- event: “uncategorized-activated”
All nice, but the problem here is: it’s not compatible with consent mode.
Consent Mode allows for tags to behave differently based on consent level
My GA4 tag flips marketing features to on when I allow marketing, and leaves it off when I don’t.
Finsweet pushes either “essential-activated”, or BOTH “essential-activated” and “marketing-activated”. So it’s impossible to configure this with 1 tag (unless you use lots of trigger groups)
So.. we have a problem.
The solution
It’s a lot of work, but not rocket science. The steps are:
- use the
fs-cc
cookie to read the consent state - create 2 variables to prepare the gtag consent mode object
- create variables for every individual consent toggle that is relevant to you
- add the “Consent Mode (Google Tags)” template to your container
- configure a default and an update tag
- create a smart trigger
- configure consent
- test and publish
Let’s go!
- use the
fs-cc
cookie to read the consent state
The cookie is called fs-cc
and needs to be URI-decoded
2. create 2 variables to prepare the gtag consent mode object
We need a default (to fall back to, when there is no cookie) and a current consent mode variable (based on the cookie)
function() { return { ad_storage: "denied", analytics_storage: "denied", functionality_storage: "granted", personalization_storage: "denied", security_storage: "granted", wait_for_update: 500 } }
And the one from the cookie:
function() { var cookie_content = decodeURIComponent(decodeURIComponent({{cookie fs-cc cookie consent status}})); var consent_state = "update"; var to_return = {{js - default consent object}}; // looks like '{"id":"bWEHY5Ex-bHZ-TQEw5dcc","consents":{"analytics":true,"essential":true,"marketing":true,"personalization":true,"uncategorized":true}}' try { var status = JSON.parse(cookie_content); to_return = { ad_storage: status.consents.marketing ? "granted" : "denied", analytics_storage: status.consents.analytics ? "granted" : "denied", functionality_storage: status.consents.essential ? "granted" : "denied", personalization_storage: status.consents.personalization ? "granted" : "denied", security_storage: "granted", wait_for_update: 500 } } catch(e) { return to_return; } return to_return }
Make sure to convert undefined
to the default variable.
The variable is named js - consent - from decoded fs-cc cookie
3. create variables for every individual consent toggle that is relevant to you
This is the part where you extract every consent toggle in a seperate variable:
function() { var c = {{js - consent - from decoded fs-cc cookie}}; return c.functionality_storage }
4. add the “Consent Mode (Google Tags)” template to your container
The community template gallery has this awesome tag by Simo Ahava. We’re going to use that
This tag has 2 modes: a default mode, and an update mode. We’re going to configure both
5. configure a default and an update tag
First, we configure the default. After that, we can COPY that tag, and change the Command and Trigger.
Now copy that tag, name it Consent Update - max once per page
and change the Command to “Update”
Leave the rest the same, and set it as “Once per page” (under “Advanced settings”)
Also change the trigger – create a new one on the fly, see below
6. create a smart trigger
We want this trigger to fire on ALL “-activated” events, but not the “essential-“.
The regext is: (analytics|marketing|personalization)-activated
7. configure consent
Almost there… You are set!
Click the shield button, and add any consent settings you want to apply to tags, and everything will just work.
8. test and publish
But test it first…
It should look something like this in the console , when the cookie popup is visible (first page load)
After your consent choice, you will see the update, and the tags will adjust themselves accordingly
Screenshots from this dataLayer inspector chrome plugin
In GTM preview mode:
So check, double check, and publish. Done.
You did it!
You reached the end of this long post. Hope it was helpful, and even though it’s a boatload of clicks to get to this result, it’s going to save you a lot of headaches.
Comments and questions welcome! The comments are open
Atle says
Hi! We have followed your guide to try setting this up, but encounter a few issues along the way when trying to publish the tag.
Validate Workspace
The workspace has the following errors:
Type Location Description
Unknown variable name js – analytics_storage Unknown variable “js – consent – from decoded fs-cc cookie” found in another variable. Edit the variable and remove the reference to the unknown variable.
Unknown variable name Js – concent – from decoded fs-cc concent Unknown variable “js – default consent object” found in another variable. Edit the variable and remove the reference to the unknown variable.
Unknown variable name Js – concent – from decoded fs-cc concent Unknown variable “cookie fs-cc cookie consent status” found in another variable. Edit the variable and remove the reference to the unknown variable.
Do you have any idea why this happens?
Looking forward to hear from you!
jules says
I think you misspelled “consent”. Make sure to name your variables in the code exactly the same as you actually call them. I see a capital J and consent written as “concent” in your error message.
Js – concent – from decoded fs-cc concent
Atle says
Yea, noticed that we had some misspell issues. Got it to work in the end! Thanks a million for this awesome guide!
Quentin says
Hi,
Thank you so much for this tutorial! Super helpful.
I confess I am a newbie, so I am sorry but could you clarify where to go to test to make sure this works (step 8)? I assume it’s in the console once I hit F12 on my website? But where specifically? :3
Here is the website if you want to have a look !
https://ernesti.fr
Many thanks !!
jules says
Hi Quentin, you can preview in GTM,before publishing.
My tutorial is quite complex, so I skipped the base stuff :)
Always preview and check everything before publishing. Always. Esp when changing consent stuff.
My screenshot is using the ‘adswerve datalayer inpector’ chrome extension. I will update the post to mention that.
Quentin says
Yes please do update the post with how to use this extension because I confess I have no idea how to check that what I did works correctly. :3
Sebastian says
Hi Jules,
this is a pretty good guide and i was able to follow except one issue.
I see that it is important to name things correctly, but in one step you configure a step “js – consent – from decode…” here is the end missing and so i had no clue after i got an error massage. But here i found out to name this thing “js – consent – from decoded fs-cc cookie”.
All Done
The end is a bit confusing how to select the categories but after a little bit of testing this works as well.
But i got one issue which i can not get fixed. When i change my consent settings with finsweet and activate “analytics” the handled Scripts are not fired directly. I have to reload the page to fire my scripts.
Is this the way or did i missed something here?
Thanks again for this pretty good guide
jules says
I’ve added the full name in the post, thanks
When you choose not to send a pageview without consent, use the “any consent given” trigger for your pageview event. Do not use the pageview, else you will indeed miss one, as you noticed.
When you choose to send a cookieless pagview without consent, use the regular “All pages” trigger.
Sebastian says
Hey Jules, do you still recommend setting up Finsweet by your blog post in July/August 2024? Same question, different words: Were there any hotfixes by Finsweet that made this unnecessary?
Thank you for sharing this awesome guide nevertheless.
Kind regards
Sebastian
jules says
AFAIK there has been no changes in de Finsweet code, so the setup I described is still valid (and needed)
Sebastian says
Alright! Thank you for the quick reply and keep up the good work :)
Sebastian says
Another question, sorry: When setting up the Google-Tag (former GA4 configuration) tag, which trigger should I use? Out of my understanding, I would use the trigger “event – any consent opt-in given”, is that correct?
jules says
If you want to collect cookieless pings, have it fire on “all pages”. That is the whole idea: you update the consent, and the tag will handle how it handles the data.
Eric says
Finsweet’s fsc-cc-consentmode=”true” does in fact set the consent default and consent updates, however, the consent default is set too late in the order of operations and it isn’t tied to consent initialization. Therefore the implementation doesn’t work as expected and cannot relied on.
The outlined implementation in this post works, however, a potential drawback is that the consent update event fires based on a custom event trigger tied to the Finsweet analytics/marketing/personalization-activated event. This means that once a cookie is set on the browser the consent update is going to fire every single page load since those events also fire on every page load instead of receiving that event only when the user has updated their consents. Finsweet fires an activated event on each page load or setting change to let you know what was activated.
Basically the page loads and sets consent defaults with values from the cookie, then it runs the consent update (since a Finsweet activated event fired) and sets the consents to the same thing it just did in the consent default operation. So you will never get another consent update to fire.