Google Tag Manager cookie banner configuration (Default)

Have more questions? Submit a request

The CookieFirst consent management can be quickly implemented into Google Tag Manager (GTM) by following the steps outlined below.

  • Implement the CookieFirst script on your website
  • Fire your Tags after consent is given for the appropriate category

Step 0: Requirements

For this guide we assume the following:

  • You already have a Google Tag Manager account
  • You already set up a container for your website
  • The GTM script is embedded on your website
  • You have an account at Cookie First, otherwise create on here.

 

If you want to embed other scripts in your website and comply to the GDPR please read this article.

 

Step 1: Integrate Cookie First

  • Add the Cookie First embed script to your website. Learn how to do that here
  • Add the GTM container to your website if you didn't do that already. 
  • Make sure the TAG manager container fires after our banner. Otherwise events of our banner might be send later than for example the pageview event. You can do this by altering the embed code depending on whether you use Category based consent or service based consent. 
    • Example category based consent: replace necessary with the category you want to assign; necessary, functional, performance, advertising
      <!-- Google Tag Manager -->
      <script type="text/plain" data-cookiefirst-category="necessary">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
      new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
      j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
      'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
      })(window,document,'script','dataLayer','GTM CONTAINER ID');</script>
      <!-- End Google Tag Manager -->

 

Step 2: Set up data layer variables

Our integration with Tag Manager works over the DataLayer to retrieve the consent status which lets you fire your tags.

1. Go to the tab Variables and from there look at User-Defined Variables

2. Click New and call the variable Performance

3. Select Data Layer Variable and put in the field Data Layer Variable Name: cf_performance_enabled and set Default value and put in there false. Then hit Save.

4. Repeat this step for every category, so:

cf_functional_enabled
cf_necessary_enabled
cf_advertising_enabled
cf_performance_enabled

Optional: set Default value and put in there false

screenshot-2020-01-09-at-13233_1txa7p5.png

 

Trigger 1

For each category we're going to set up a trigger. Go to the tab on the left called Triggers

  1. Click New
  2. Call it Opt-in Performance (for the performance category). On Trigger type choose Custom Event.
  3. Under Event name put in this case cf_consent_performance
  4. This trigger fires on Some Custom Events
  5. Select the variable we created Performance and then equals and fill in true
  6. Repeat this step for every Variable we created in the previous step. Use the event names below for the categories.
cf_consent_performance
cf_consent_functional
cf_consent_advertising
cf_consent_necessary

screenshot-2020-01-09-at-14551_1mh2d0l.png

Step 4: Customise your Tags

In this part we will set up Google Analytics in the performance category. Remember to set the analytics also to anonymizeIP.

1. Open the tag. Or add it if you haven't done that already.

screenshot-2020-01-09-at-15494_a7epb3.png

2. Under Triggering choose your predefined Trigger. In this case Opt-in Performance.

3. Because we already set the default value of the variable to false we do not need to set any exceptions.

4. Save the tag and repeat this step for every tag assigning it to the right Trigger and category.

 

For necessary scripts you can obviously also set this up but Necessary scripts can always be executed so you could also not put them in here.

 Disclaimer: CookieFirst cannot be held liable for misconfigurations of our banner, you are solely responsible of setting it up in a correct way which complies to the GDPR

Articles in this section

Was this article helpful?
15 out of 42 found this helpful
Share