How to block cookies and trackers with Google Tag Manager (GTM)

Avatar

By Dan Storbaek

updated 2 months ago

In this article, we assume that you have already created a GTM account, created a website container in GTM, and added the GTM container snippet to your website as required: https://support.google.com/tagmanager/answer/6103696.

We also assume that Secure Privacy is already installed. To know more about how to implement Secure Privacy with GTM, read this article.

To block cookies and trackers, you need to add triggers of the respective script tags on your GTM. Follow these steps to add triggers to your GTM.

  1. From the GTM “Triggers” list, click “New”.
  2. Choose “Custom Event” and enter an event name for the trigger.
  3. Type sp-consent="PLUGIN NAME”, in the field “Event name”. (The plugin name should be copied from your scan report page)

    If you are blocking Google Analytics, your configuration should look like this. We have named the trigger as SP-Consent-Google-Analytics

    trigger-1024x363.png

  4. Click “Save” to create the trigger.
  5. Repeat the above for each type of plugins, so that you have all triggers created on your GTM.
  6. Now that you have created your Trigger, you need to attach it to their respective Scripts. Your Next steps will depend on the Plugin which you need to block. In this article, we are taking Google Analytics as an example.
  7. Create the Universal Analytics tag by clicking “New” from the Tags list – or edit your existing Universal Analytics tag.
    If creating a new tag, select “Universal Analytics” under the “Choose tag type” pane. Select “New Variable” in the select box under “Google Analytics Settings” and enter your GA Tracking ID (available from Google Analytics) in the field “Tracking ID”. Click “Save”.
  8. As a trigger, select the trigger you have just created, “SP-Consent-Google-Analytics”. Click “Save” to create or update the tag.

    This is what your final Universal Analytics tag configuration should look like (except for the Tracking ID):

    google-trigger-1024x548.png

  9. Finally, click “Publish” to push your changes live to your site.

 

 
Note: If you are using multiple triggers on a tag, then follow this article to enable cookie blocking. https://knowledgebase.secureprivacy.ai/article/3-how-to-block-cookies-with-multiple-gtm-triggers

 

Did this answer your question?