Google Tag Manager initial setup

You can easily integrate CookieHub with Google Tag Manager (GTM) and use the provided triggers to conditionally load tags based on user consents.

CookieHub will automatically push events and variables to the dataLayer when a cookie category is allowed or denied which can be used by created triggers in GTM. You can manually create the triggers in GTM or import the provided recipe into your container.

Data layer events

If you import the CookieHub GTM recipe you don’t have to define events manually, but in case you want to do it manually or customize the GTM implementation here is a list of events:

Name Fires when…
cookiehub_ready CookieHub has loaded and is ready to use
cookiehub_modified a user has made any change to allowed or denied categories
cookiehub_necessary The Necessary cookie category has been allowed, either because it has previously been allowed or the user enabled it in the settings dialog or by clicking the Allow all cookies button.
cookiehub_preferences The Preferences cookie category has been allowed, either because it has previously been allowed or the user enabled it in the settings dialog or by clicking the Allow all cookies button.
cookiehub_analytics The Analytics cookie category has been allowed, either because it has previously been allowed or the user enabled it in the settings dialog or by clicking the Allow all cookies button.
cookiehub_marketing The Marketing cookie category has been allowed, either because it has previously been allowed or the user enabled it in the settings dialog or by clicking the Allow all cookies button.
cookiehub_uncategorized The Uncategorized cookie category has been allowed, either because it has previously been allowed or the user enabled it in the settings dialog or by clicking the Allow all cookies button.
cookiehub_click_allow_all Triggered when a user clicks the Allow all cookies button
cookiehub_click_deny_all Triggered when a user clicks the Deny all cookies button
cookiehub_click_open_settings Triggered when a user clicks the settings icon or the Cookie Settings button
cookiehub_click_save Triggered when a user clicks the Save settings button in the Cookie Settings dialog
cookiehub_click_learn_more Triggered when a user clicks the Learn more link

Data layer variables

The state of each category is stored in data layer variables that can be used in GTM to customize the loading of tags based on users selection, the variables stored are:

Name Type Default value
cookiehub_necessary Boolean false
cookiehub_preferences Boolean false
cookiehub_analytics Boolean false
cookiehub_marketing Boolean false
cookiehub_uncategorized Boolean false

Importing the CookieHub GTM recipe

The CookieHub GTM recipe will create a tag for CookieHub v2 and triggers for all cookie categories that you can use as firing triggers.

Importing the recipe won’t change your current tags and triggers in GTM unless you are upgrading from a previous version of the CookieHub GTM implementation.

1. Login to Tag manager

2. Open the container you want to integrate CookieHub into

3. Click Admin from the top menu to enter the administration for the container

4. Click  Import Container in the  Container section

5. Download the  CookieHub GTM recipe

6. Select the CookieHub GTM recipe as the  container file, select your  workspace and select  Merge in import option.


Please note! Make sure you select Merge in the import option to avoid removing your current tags and triggers.

7. Once you have done everything from step 6 you will get an overview of added and modified tags. Click the Confirm button to complete the import.

 8. Now, we’ll have to add your CookieHub Domain Code to the newly inserted CookieHub tag. Click Tags in the left menu to show a list of tags in your workspace.

9. Click the CookieHub tag and the edit window will be shown:

10. Replace the xxxxxxxx with your CookieHub Domain Code available in the CookieHub as shown below:

11. Now you’ll only have to save your tag and CookieHub is ready to use in your GTM workspace. We have included two different sample tags to show how the triggers should be configured.

There are two methods to load your tags:

Only use the Allowed trigger as shown in the Sample Tag. This method will load the tag when the page is loaded and the analytics cookie category has already been allowed or if the cookie category was allowed by clicking the allow all button or using the cookie settings dialog.

The other method is shown in the Sample Tag with Exception. This method will load the tag if a category has not been allowed when another trigger is fired.

Please note that the firing trigger can’t be All Pages or other page views triggers because they are triggered before CookieHub is loaded by GTM. If you want your trigger to be All Pages, use the trigger CookieHub – Loaded instead.

12. The final step is to place the correct triggers on all your tags and you are ready to go.

Still need help? Contact Us Contact Us