CMS Development

Ramifara
Participant | Diamond Partner
Participant | Diamond Partner

GDPR compliance cookie implementation.

SOLVE

Hi Friends,

I am a bit new to HubSpot, and this question might be super simple but it has puzzled me for days. 

Q: Is there anyway to add a script to the absulute top of <head> before all defult scripts that hubspot will inject? 

Story: I am trying to implement a cookie concent banner ( tried many different tools) but they all face the same problem, the scripts that need to wait for and check consent after reload all run before the consent script gets executed. meaning that when you land and pick your cookie preferences it works fine but as soon as you reload, everything comes back and breaks the consent. 

As I have read elsewhere on form i could try to use this hubl filter to change the script types for both head and footer scripts, so the consent handeler will run the scripts if needed

{{ standard_footer_includes|replace('type="text/javascript" id="hs-script-loader"','type="text/plain" id="hs-script-loader" data-cookieconsent="marketing"') }}

But this is not the best solution and will not work in all situations. 

Is there a better solution out there to fix this problem?

Thanks
 

0 Upvotes
1 Accepted solution
Sjardo
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

GDPR compliance cookie implementation.

SOLVE

Hi Ramifara,

 

You could think of https://www.cookiebot.com/en/ It has an implementation option trough GTM.

Hubspot itself has some pretty decent cookkie settings themselfs. If you have some time and access, try it out!

 

View solution in original post

7 Replies 7
Sjardo
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

GDPR compliance cookie implementation.

SOLVE

Hi Ramifara,

 

You could think of https://www.cookiebot.com/en/ It has an implementation option trough GTM.

Hubspot itself has some pretty decent cookkie settings themselfs. If you have some time and access, try it out!

 

Sjardo
Top Contributor | Elite Partner
Top Contributor | Elite Partner

GDPR compliance cookie implementation.

SOLVE

Hi Ramifara,

 

Sadly, if you don't have access to the source code, to my knowledge, it's not possible.

 

There is simply no way of pushing something as first into the head within HubSpot withouth code. HubSpot is kind of "locked down" if you dont work with .html files. You can push data into the head, but not on the very top withouth the .html files.

 

Thats why I created an own custom template for our site, www.bureauvet.nl, which gives me the ability to load GTM and a speed tracking script first, before everything else.

 

I hope this helps out a bit!

 

Ramifara
Participant | Diamond Partner
Participant | Diamond Partner

GDPR compliance cookie implementation.

SOLVE

Fair enough, This makes total sense and was super helpful thanks. 

I guess the only way to go forward in those situations, is to find a cookie handler that does not require high-level placement or script manipulation. Which luckily there are some. 🙂

unless the client has already paid for a year subscription of the one that won't work.  

One other way that I think would work is using google tags. I have not tested it but some cookie tools use to have it as an option instead of using the script

Thanks again!

0 Upvotes
Sjardo
Top Contributor | Elite Partner
Top Contributor | Elite Partner

GDPR compliance cookie implementation.

SOLVE

Hi,

The way we do this, is making sure you use (or convert to) .html files for templates and modify the source. This way you can do or load whatever you want, in every place you can think of!

I hope this helps!

Ramifara
Participant | Diamond Partner
Participant | Diamond Partner

GDPR compliance cookie implementation.

SOLVE

Thanks for taking the time first! 

This would mean that when I work on a client account where we don't have access to the source file, there is no way around this problem, correct? 

 

also, I had the same idea and tried to implement it by placing the cookie script to the top-level <head> in the base file of my theme, but Hubspot still injected their script loader before my script which messed up the work again. also when looking around in the source file I can not actually find the tracking scripts the HubSpot injects in order to change their type to text/plain as it is required for some cookie tool. 

Thanks, 


Rami Fara
Front-end developer & UX/UI Designer

0 Upvotes
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

GDPR compliance cookie implementation.

SOLVE
Thanks Dennis

If you’re using a theme you could duplicate (the theme or head) and modify the head.html template partial.

Hope this gets ya moving!
Kevin Cornett - Sr. Solutions Architect @ BridgeRev
dennisedson
HubSpot Product Team
HubSpot Product Team

GDPR compliance cookie implementation.

SOLVE

@Kevin-C , any ideas here?