Cookie Banner Configuration with Google Tag Manager

You can implement Privacy Pillar's cookie banner on your website with Google Tag Manager (GTM) by following the instructions given below.

Get Started with Google Tag Manager

  1. Go to https://tagmanager.google.com/ and log in to your account.
  2. Create a new container.

Follow the steps to create a new variable for Accepting the cookies. 

  1. Go to your website's workspace in GTM.
  2. In the left pane, click Variables.
  3. In User-Defined Variables, click New.
    Variable configuration appears.
  4. Replace "Untitled Variable" by entering the name "PrivacyPillarCookieAccepted".
  5. In the Variable Configuration, click .
    Choose variable type appears.
  6. Under page variables, select Data Layer Variable.
    Data Layer Variable configuration appears.
  7. In Data Layer Variable Name, enter "PrivacyPillarCookieAccepted", and click Save.
    The created variable appears under the User-Defined Variables.

Create Watcher Tag and Trigger

The following is the procedure to create a watcher tag and a trigger

  1. In the left pane, click Tag, and in the Tags container, click New.


    Tags and Triggering configuration appears.
  2. Replace "Untitled Tag" by entering any Tag Name.
  3. In Tag Configuration, click .
    Choose tag type list appears.
  4. In the list, select Custom HTML.
    A custom HTML editor appears.
  5. In the HTML editor, insert the below code snippet.
    <script>
    window.addEventListener('ConsentActivity', function (e) {
        if (e.detail.purpose.advertising) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'advertising'
            })
        }
        if (e.detail.purpose.analytics) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'analytics'
            })
        }
        if (e.detail.purpose.essential) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'essential'
            })
        }
        if (e.detail.purpose.functional) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'functional'
            })
        }
        if (e.detail.purpose.social_media) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'social_media'
            })
        }
        if (e.detail.purpose.uncategorized) {
            dataLayer.push({
            'event': 'PrivacyPillarUserPrefUpdate',
            'PrivacyPillarCookieAccepted': 'uncategorized'
            })
        }
    }); 
    </script>
  6. In Triggering configuration, click .
    Choose a trigger appears.

  7. Click .
    Trigger Configuration appears.
  8. Replace "Untitled Trigger" by entering any Trigger name.
  9. In Trigger Configuration, click .
    Choose trigger type appears.
  10. Under Page View, select DOM Ready, and click Save.
    It backs to Tag Configuration.
  11. Click Save.
    The custom HTML and trigger are added to your container.

Since there are six-cookie categories, you must create separate triggers for each category given below.

   1. advertising 
   2. analytics
   3. essential
   4. functional
   5. social_media
   6. uncategorized

Follow the steps to add separate triggers.

  1. In the left pane, click Triggers, and in the Triggers container, click New.

    Trigger Configuration appears.
  2. Replace the "Untitled Trigger" by entering the name in the "<cookie category> Trigger" format.
    (for example, Analytics Trigger)
  3. In Trigger Configuration, click .
    Choose trigger type list appears.
  4. In the Choose trigger type list, under Other, select Custom Event.
    The custom event is added to the configurator.  
  5. In Event name, enter "PrivacyPillarUserPrefUpdate", then select the Use regex matching check box, and select Some Custom Events.
    It asks for events parameters.
  6. Enter the following parameters.
    ▷ In the first field, select PrivacyPillarCookieAccepted (the custom variable created).
    ▷ In the second field, select matches RegEx (ignore case).
    ▷ In the third field, type "<cookie_category>".
        Where "<cookie_category>" must be one of the available categories verbatim (for example, "essential").
  7. Click Save.
  8. In the same way, create individual triggers for each <cookie category>.

To each existing tag that controls your cookies, add the category triggers so that they drop cookies only when the watcher receives the Privacy PillarUserPrefUpdate object from Privacy Pillar.

Follow the steps to add category triggers to the existing cookie tag.

  1. In Google Tag Manager, choose Tags at the top-left of the page.
  2. From the tags list, choose a tag that manages a cookie category—for example, Advertising.
  3. In the tag panel, at the top-right of the Triggering, click Edit.
  4. In the Choose a Trigger panel, choose the corresponding tag you created.
  5. In the tab panel, click Save.
  6. In the same way, add category triggers for all cookie tags.