Control tracking and cookie setting from the outside via tag manager


We are hosting our website through the Hubspot COS and with the GDPR deadline coming up, our company is implementing a third party cookie consent solution (OneTrust). For this to work we need to be able to tell Hubspot somehow (e.g., via cookie), that it should not embed the HS analytics/tracking code. As a side note: We will implement the cookie consent manager with Google Tag Manager

Support gave me the hint to use the Hubspot cookie banner and then use CSS to hide it and emulate a button click, but that sounds really improvised to me and not really like a professional solution.

Does someone have an idea how this could be solved?

Thanks a lot for your help


Very relevant question. Dealing with the same issue at the moment.
Mixed hosting between Hubspot COS and another provider. Need to be able to control Hubspot cookies through Google Tag Manager on Hubspot hosted content.

Looking for a professional solution rather than a workaround/jury-rig.


Hi @alexpeiniger & @Niklas_S,

Regarding cookies: HubSpot will update the default language for enabling cookies on HubSpot-hosted websites to reflect affirmative opt-ins, and make it possible to show different versions of the cookie consent message based on domains or specific URL paths that you specify.

Additionally, functionality will be added to the Tracking Code API to trigger cookie deletion. It's not finished yet, but stay tuned for updates on that front. Additionally, check out our GDPR Product Readiness page for details/updates on product changes related to GDPR:


Is there any update on this? - I've been looking at cookiebot, however if a built function exists that'd be much better.


Hi @mattdev,

You can now manage cookies via the Tracking Code API:


Also dealing with this. Using OneTrust in combination with WordPress and Hubspot Landing pages/blog.

I used this blog article:

Think I saw another thread where someone recommended this, or if I just stumbled across the article when googling...
The standard recipe in that blog article suggests running HubSpot tracking Java Script only if OneTrust Cookie consent is given. As a side-effect it is not possible to track from where the website visitor came.

Beside this it seem to work on WordPress.

The HubSpot hosted blog and Landing pages (two different sub-domains) are different stories. Not sure how to treat that yet. Anyone have some advices?
My idea is to:

  • Try to hide or disable the cookie consent banner using
  • Find some injection point which allows me to run the Google Tag Manager Java script only for Landing pages and Blog pages. Dont know where yet...
  • Setup Google Tag Manager to set the necessary cookies for enabling disabling tracking.

A lot of new tools to digest, so progress is slow and lots of trial and error. Anyone else thinking along these lines, or are there better alternatives?