2. Blocking Third-Party Cookies and Google Tags using GTM
If you are using Google Tag Manager (GTM) to insert certain third-party cookies or Google Tags on your website, you can implement GTM with Mandatly's Cookie Compliance Solutions to control those cookies' and tags behavior.

Mandatly has pre-configured events which can be easily integrated with GTM based on Cookie Category ID. Mandatly events are fired for all the website pages with the banner.

Let us walk through an example of implementing the Google Analytics tag:

  1. Add Mandatly Consent Banner code (link: integration with GTM)
  2. Create Trigger:
    Go to the Triggers and add a new trigger; the following page will be displayed. Click on the "Choose a trigger type to begin" and add a "Custom Event".

    To implement GTM with Mandatly Solutions, name the event as "MandatlyDataCategory-0003", 0003 suggests the Cookie Category Id.

    Suppose 0003 is the Cookie Category Id for Analysis Category, so this tag will be fired when the user sets the Analysis category as Active and consents to the banner.

    Replace 0003 with the Cookie Category Id you want to fire.


    Click on the "Save" and name the trigger.

  3. Implement Trigger:
    Go to the Tags section and open a Tag created by you.

    Click on the "Choose a trigger to make this tag fire" and select the trigger created by you.


    Click on the "Save" button. 


    Click on the "Submit" button and publish it.

    With this, you have successfully implemented GTM with Mandatly's Cookie Compliance Solution.  The google analytic cookies will load after the user sets the "Analysis category" on the banner as "Active" and consents to the banner.


Notes:

  1. Please ensure that the events triggered in Google Tag Manager (GTM) are consistent with the cookie categorization you have configured in Mandatly. It is essential to routinely audit your GTM scripts and events in relation to the cookie categories maintained in the preference center of your website configuration. If there is a discrepancy between the GTM scripts and the cookie categorization, there is a risk of displaying incorrect banners, which could lead to obtaining inaccurate consent.
  2. Manual Blocking Script option needs to be enabled while using the Custom tags, Custom events or GTM events on your website.  To enable the Manual Blocking Script option in your Mandatly account:
    Navigate to Websites -> Edit website -> More Settings and turn on the Manual Blocking Script option.


How to map your Custom Triggers to Mandatly Triggers:

If you have already created custom triggers in GTM and do not wish to change them for Mandatly implementation, you can use instructions provided here to map one or more GTM trigger to Mandatly Event/trigger:

  1. Add Mandatly Consent Banner code {link: integration with GTM}
  2. Follow the “Create Trigger” instructions provided above to create the Mandatly Trigger(s). 
  3. Assume you have already created a custom trigger named ‘CustomCategory-0002’.


  4. Navigate to Tag -> Create New Tag.
  5. Choose Custom HTML as the Tag Type, and paste the following script.

<script>
 window.dataLayer = window.dataLayer || [];
  dataLayer.push({'event': ‘CustomCategory-0002'});
</script>


  1. Replace 'CustomCategory-0002' in the script above with the name of your custom trigger.
  2. Add the appropriate Mandatly Trigger in the Triggering section.
  3. Click on the "Submit" button and publish it.


In above example, google analytic cookies will load after the user sets the 0002 category on the banner as "Active" and consents to the banner. With this, you have successfully mapped your custom triggers with Mandatly triggers/events.


Relevant Resources: