Hubspot, Google Tag Manager and cookie consent


Hi there


I am trying to set up a GTM container where tags get fired in accordance with the consent given via the Hubspot consent banner.  

I have done this many times with cookie management platforms (Cookiebot, Cookieinformation etc.) without any difficulty but these tools have been integrated quite well with GTM (templates/custom events being pushed on consent). 

I was hoping I could use the value of the __hs_opt_out cookie as a condition for my tags to fire. As described in these blog posts:


The problem is that a visitors cookie consent only sends tracking data on any additional page views. Data from the first page view where consent given is lost - for GA it could be source and refererrer -


Has anybody solved this predicament? I have found a post regarding the problem but no solution in the Hubspot community.

I hope this can be fixed in Hubspot or GTM without any hardcoding (I am not a developer and my client doesn't have one at hand)?


Maybe some settings can be adjusted in Hubspot (or a script implemented from the account) or a custom HTML tag with the proper code can be used in GTM to fix the issue?

Any help will be VERY appreciated.



3 Replies 3
Community Manager

Hello @KKvistgaard, I will add some top experts to share their ideas, @himanshurauthan @Phil_Vallender any recommendations to @KKvistgaard matter?


Thank you,


Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


Hi Pam &  @himanshurauthan @Phil_Vallender

Thanks for the assistance. 

In terms of tracking properly in GTM whicle respecting consent (via Hubspot) maybe it could make a difference if the GTM container was implemented via Hubspot (it's hardcoded at the moment)?

The documentation mentions:

Please notethe cookie policy banner blocks HubSpot cookies and cookies from HubSpot integrations, including Google Analytics and Google Tag Manager. HubSpot can only block these cookies if you use the integrations. HubSpot cannot automatically block cookies from scripts you manually place on the page.

Would the GTM container just be blocked without consent and would custom events be made available for triggering all pages tags (as is the custom with the solutions from other Cookie Management Solutions) when consent is given?

Maybe the solution is something completely different?




Please disregard this post. Subdomains are hosted in Hubspot but main domain is external - so I wont be able to implement GTM via Hubspot in terms of the main domain... but I still need to get GTM and the Hubspot consent solution to work on the main domain (works on the hosted subdomains where GTM is also integrated with Hubspot).

Hope for your assistance