Managing HubSpot cookies when you use a third party cookie management tool
Nov 12, 2020 3:56 AM - edited Nov 14, 2020 6:40 AM
The worst thing about working in tech? Cookies no longer have the delicious connotations they once had...........
Here is a solution that will assist you in managing HubSpot cookies when you are leveraging a third-party tool.
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.
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).
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 ***