Anonymize Hubspot cookies



I have to modify my website so that I can comply with the GDPR. In order to do this I'm searching a way to anonymize the cookies that HubSpot installs in the client's browser (like Google Analytics with _ga('set','anonymizeIp',true) function).

Can someone help me with this?
Thanks a lot


Hi @Michele_Faccioni,

You can use the following Tracking Code API methods to handle consent, remove cookies, and set 'doNotTrack' status:


Hi @Derek_Gervais.

Should I be clearing any other hubspot cookie at the same time? These include;__hssc, __hssrc, __hstc, hubspotutk. I wonder if any of these need to be removed, anonymized or have the expiry set to session.

And should 'donottrack' be called before or after the hubspot tracking script?

For reference I built a custom cookie consent script in google tag manager, which checks for the presence and value of a cookie. (similar to the hubspot version).
Only if the cookie value is set to 'allow', does a trigger call the hubspot tracking code.

I'd like to be able to add a trigger to call the tracking code with do not track enabled, based on when a user declines cookies.



Hi @mattdev,

The 'Remove cookies' function of the Tracking Code API will remove all cookies set by the tracking code; you don't need to specify which cookies are removed or worry about other cookies. The tracking code needs to be loaded in order to use any of the methods of the Tracking Code API, so I'd advise making sure the tracking code fires before calling the 'Place do not track cookie' method.