Enabling / Disabling Tracking Script via 3rd Party Cookie Banner

Hello,

My organization requires us to use a 3rd Party Cookie Management Tool (OneTrust).

As a result, I’m looking to understand what is the best way to enable and disable the analytics tracking script via the OneTrust cookie banner.

After consulting this article (Consent banner API - HubSpot docs), our approach is to place the Do Not Track cookie by default via Google Tag Manager and then enable tracking via a GTM script that sets “_hsq.push([‘doNotTrack’, {track: true}]);” and then disable via a script that sets “_hsq.push([‘doNotTrack’, {track: false}]);”

Does this seem like an appropriate approach? Is there a better way?

Hi @tjnauman,

Thank you for reaching out to the Community!

I wanted to refer you to this related thread from the Developer’s Forum regarding OneTrust Cookie Banner.

I also wanted to add our subject matter experts to this conversation to see if they have any thoughts.

Hi @Teun, @Anton, @LMeert - Do you have any insight for @tjnauman regarding their approach to enabling and disabling the analytics tracking script?

Thank you!

Best,

Kristen

Hi @tjnauman,

It is indeed the best way : add the do not track cookie by default and then remove it when the user approves the tracking through the One Trust banner.

Especially if you’re on HubSpot CMS since you cannot remove the tracking script which is added to your pages by default.

Hope this helps !
If it does, please consider marking this answer as a solution :slightly_smiling_face:

Best,

Ludwig