Often little or nothing changes when a visitor does not accept cookies on a website. Cookies are still active, and third-party scripts are being loaded.
We 'll show you how to change that combining the HubSpot cookie settings with Google Tag Manager.
Activating HubSpot's default cookie bar only helps your users accept/refuse HubSpot's cookies. Out of the box, HubSpot's cookie bar does not control other cookies you offer through your site (think of Google, Facebook, ...).
And that's not what you want, right?
A technical deep dive:
The first cookie, which is primarily used to keep track of the visitor's choice, is therefore an _opt_out_cookie with the value "yes". We will now read this cookie in Google Tag Manager.
To prevent external scripts from being loaded, we create a new trigger in Google Tag Manager based on the opt-out cookie. How to do this:
We create a variable in Google Tag Manager that will contain the value of the cookie.
If you have a simple value like 1, 0, true, false ... in your cookie, you don't have to do anything with the other options in this screen.
Your variable is now ready and appears in the overview:
The variable we just created will now be used in a new trigger. A trigger listens on your page (or app) to certain types of events: forms that are sent, clicking on buttons, loading a page, ... A trigger also ensures that a tag is loaded or blocked when certain conditions are met or just not.
We set up our trigger as follows:
Now that we have created our trigger, we can use it for the tags.
Save your modification for this tag and do the same for all other tags you want to load this way.
With the preview function of Google Tag Manager you can now first check your changes without them being immediately applicable to all visitors to your site.
If you also want to be fully compliant with your cookie policy, use the hack above to setup your GTM correctly. Or talk to one of our experts!