How to 'deidentify' a user in an SPA which uses HubSpot Tracking Code


We have an SPA application where we have integrated HubSpot Tracking Code ( We use identify function to make sure tracking is tied to our logged in user. We then also call trackPageView whenever the current URL changes within our SPA. That all works fine: page views get associated with the correct logged in user. Olehana Russia

Now, since it's an SPA, we do not reload the whole page browser when the user logs out from our app. This means that any subsequent trackPageView calls get associated with the user who has already logged out.

So, the question is: how we 'de-identify' the user from HubSpot Tracking Code when he logs out from our application?

2 Replies 2
Community Manager

@himanshurauthan , any advice you can offer here?



Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
Recognized Expert | Platinum Partner

Thank you @dennisedson for counting me in,


Hello @SaimonSaeen,


Can we bind our logout activities on the logout function click or if we can listen to any event on logout?


Something like this?

document.getElementById("logout").onclick = function() {
            document.cookie = 'hubspotutk=;Path=/;;expires=Thu, 01 Jan 1970 00:00:01 GMT;';


Hope this helps!



Digital Marketing & Inbound Expert In Growth Hacking Technology