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.
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:
Hi there,
We have a similar issue, we hope you can help with.
-We use AngularJS which is Single Page Application (SPA)
In a normal webpage system the HUBSPOT javascript plugin, reloads when each page loads
-Now in our SPA application the page never really reloads/refreshes the view.
-So we use the standard AngularJS handler which basically fires on each page load it’s called stateChangeSuccess
$rootScope.$on(’$stateChangeSuccess’, function
_hsq.push(["identify", {
email: cur…