The cookie consent banner premium add-on is able to manage the Google Tag Manger (GTM) snippet for you.
In that way the loading behavior of the GTM snippet is optimized for the cookie consent.
In combination with the cookie banner plugin this is the recommended way of implementing the GTM. The main benefits:
- If you want to block the GTM with “Service Blocking” the plugin takes care of the loading or not loading of the GTM. NO reload required.
- The plugin makes sure that the timing of the scripts are right.
- Increased the compatibility with caching plugins
This plugin just installs the container. Which is sufficient if you do not have special tracking needs. If you want to track orders or more information, I recommend using this plugin: https://wordpress.org/plugins/duracelltomi-google-tag-manager/
See further down in this article how to configure it together with the cookie banner plugin.
To let the Cookie Banner Plugin inject the Google Tag Manager code, just put in the GTM Id in the field “GTM ID”. That’s it.
GTM4WP & Beautiful Cookie Banner
If you want to make use of the advanced dataLayer functionalities of the GTM4WP plugin AND of the optimized Google Tag Manager loading behavior of the Beautiful Cookie Banner Plugin: You can.
Just set the “Container Code ON/OFF” setting in the GTM4WP Plugin, to “Off”. That’s it.
Now you need to configure the GTM container so that the tracking tags fire accordingly to the consent.
This feature manages the loading of the GTM, but the loading of the other tracking snippets still needs to be managed within the GTM.