Blog, Website & Page Publishing

kaburke
HubSpot Employee
HubSpot Employee

Managing HubSpot cookies when you use a third party cookie management tool

The worst thing about working in tech?  Cookies no longer have the delicious connotations they once had...........

 

giphy.gif

 

Here is a solution that will assist you in managing HubSpot cookies when you are leveraging a third-party tool.

 

We know that HubSpot cookies are managed by the HubSpot banner so we can set up the HubSpot cookie banner as per this post.  Turn on all of the options to use cookies, notify visitors that your site uses cookies and require opt-in.  When you do this and enter the relevant URLs/domain, as long as the tracking code is firing you will now see the HubSpot cookie banner firing across all pages.

 

image-Jul-15-2020-04-08-24-08-PM.png

 

But for this solution, you don't want the users to see the HubSpot banner because they have a third party banner, so let's make it invisible!  In the website stylesheet, add the below code which will target all of the HubSpot cookie banners that are loading and set them to disappear.  This means that the banners are loading but they cannot be viewed.

 

image-Jul-15-2020-04-12-01-29-PM.png

Next up, in your third party tool, you need to build in logic so that when the 'accept' option for HubSpot cookies is selected the below JS fires.  Essentially what is happening in the below code is 'an invisible hand' clicking on the 'accept' button in the HubSpot banner that has been hidden.  You can see this in action here (my test website) so that when you click on the red 'Accept' button it selects the 'Yes' button in the HubSpot banner (that I haven't hidden for this purpose).

 

image-Jul-15-2020-04-14-54-23-PM (1).png

 

What about if they don't accept the HubSpot cookies? 

Do nothing! The main reason that HubSpot requires the drop of the __hs_do_not_track cookie is that it stops us constantly asking the user for permission again but we have already used the CSS code above to hide this banner so we don't need to drop the __hs_do_not_track cookie.  If the banner has been set up correctly we will also not drop cookies unless we are explicitly told to (eg. require to opt in).

 

What about if they accept cookies and later decide to delete them?

No problem!  Build-in logic that if they decline the cookies then we remove cookies as per the logic you can find here.

 

I hope that people find this helpful!

 

*** Before implementing anything regarding compliance, it is important that you check with your legal team whether the solution meets their requirements ***

5件の返信
kaburke
HubSpot Employee
HubSpot Employee

Managing HubSpot cookies when you use a third party cookie management tool

Hi @lsmith77 !  The comment with those links in relation to the particular query from GZakraoui.  This post goes through how to leverage a banner and css to manage cookies for those that do not have coding experience.  I am not aware of a way that you can opt in people via API.  It may be best to start a new thread with this query.  Sorry I am no longer a Technical Consultant so not sure what improvements have been made in the meantime with this feature!

0 いいね!
lsmith77
投稿者

Managing HubSpot cookies when you use a third party cookie management tool

@kaburke Following your links I landed on https://developers.hubspot.com/docs/api/events/cookie-banner

What is not clear to me from this page is if I configure my cookie consent policy to be opt-in, what API call do I need to do in order to opt-in as I only see an API call to opt-out.

_hsq.push(['doNotTrack']);

 
And an API call to remove the opt-out:
_hsq.push(['doNotTrack', {track: true}]);
 
But no longer opt-out is not the same as opt-in.
 
So I am looking for something like:

_hsq.push(['doTrack']);

 
 
0 いいね!
kaburke
HubSpot Employee
HubSpot Employee

Managing HubSpot cookies when you use a third party cookie management tool

Hi @GZakraoui !  Yes we have more information here, this solution is an old one and for those that don't have that much code experience!  My understanding of your question is that when a customer who has previously declined cookies and then updates their settings so that they consent to being tracked, you want to be able to start to track them again.  This was something that at the time I was not able to figure out as you would either need to wait until the revoke cookie expires or you would need to clear the cookie and then update but this would require a refresh which I was unable to figure an eloquent solution to.  How often is this likely to occur though?  🤔 I havent looked through our docs recently and I know that there have been loads of updates.  Have you checked this out?  

GZakraoui
参加者

Managing HubSpot cookies when you use a third party cookie management tool

Hello @kaburke, reviving this thread to talk about another workaround i found out about tweaking yours.

It looks like when you don't have a cookie  policy published, you're still able to revoke cookie consent by calling 

_hsp.push(['revokeCookieConsent']);

but, navigating from page to page will set cookies back, so just calling it conditionally given the preferences set in your banner on page views will do the trick.
But i couldnt figure out or find the opposite command : so for example when a user changes the cookie preferences in your third party banner, a command to trigger to grant it back.

is there a command that grantsCookieConsent programatically ?

Thanks in advance

0 いいね!
kaburke
HubSpot Employee
HubSpot Employee

Managing HubSpot cookies when you use a third party cookie management tool

The same day I post this the Cookiebot integration gets released!!!!! 😂 https://support.cookiebot.com/hc/en-us/articles/360015961639-Cookiebot-HubSpot-integration