Manually invalidating user cookie token?

contacts

#1

Hi there!

I was wondering if Hubspot provides a javascript api to invalidate or regenerate tracking cookies stored. For example, if a user logs out of an account and another user logs on, I would like a way to regenerate the cookie hubspotutk token so that the second user can have tracking associated with their Contact record and not the first user.

I see a list of cookies Hubspot adds here: https://knowledge.hubspot.com/articles/kcs_article/reports/what-cookies-does-hubspot-set-in-a-visitor-s-browser Should I manually expire or delete these cookie(s)? Do I need to notify Hubspot’s tracking scripts that the cookie has expired?

Thank you for any help on this (or let me know if this a duplicate and I will merge / take it down).
-Michael


#2

Hi @michaelhubspot,

When a user logs out, you could remove the hubspotutk cookie from their browser using something like $cookies.remove('hubspotutk') When a user logs in, you could identify them using the Tracking Code API (see documentation below). The following forum post also touches on some of the same methods, and is worth a read:


#3

Thank you @Derek_Gervais, this should work for my use case.