At work, I was tasked with creating a new cookie consent popup and a system to connect it to all of our external tags and scripts. Not long ago Google added a new Consent Mode in GTM that is now fairly stable and ready to be used.
To use this new system you need to activate it in your container settings in GTM. After doing this you will have a few new tools to limit what tags fire based on what consent modes the user allows.
There are a few existing templates for Consent Mode, but the majority of them are for specific Cookie providers. The best template for a general implemenation I found was the one Simo Ahava has created, but this is where I encountered some issues. The tags were not firing in the right order.
After a conversation with Google, we have been able to figure out that the issue was that I was using "url_passthrough" on the tags that set the consent. Setting this kind of parameters can cause a delay in the firing process, which it clearly did for us.
After deactivating this setting, the tags are now firing in the right order.
The next step was to set a consent mode for each of the tags based on what consent is needed for that specific tag. For example to set that a tag should only trigger when "ad_storage" access is granted, we do this: