# Reset identity via js api

**URL:** <https://community.hubspot.com/t/reset-identity-via-js-api/11519>\
**Category:** APIs & Integrations\
**Tags:** events\
**Created:** [February 8, 2018, 2:12pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519 "2018-02-08T14:12:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cras6](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cras6/32/22074_2.png) [@cras6](https://community.hubspot.com/u/cras6)\
**Post date:** [February 8, 2018, 2:12pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/1 "2018-02-08T14:12:43Z")

</div>

Is there a way to reset the users identity via a Js API call/method? We have a use case where we need to clear out the Hubspot session to allow for a new user to submit a form without modifying the existing users contact record or activity. I know that there is an option for forms to be cookieless but that isn’t a desirable solution for our use case

I know “segment” has a resetIdentity method that allows you to do this but I can’t find anything in the Hubspot docs.

Current alternative is to delete all the Hubspot cookies prior to next submission. Not ideal but may be only option.

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [February 8, 2018, 10:53pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/2 "2018-02-08T22:53:29Z")

</div>

Hi [@ckwiat](https://community.hubspot.com/u/ckwiat),

You’ll need to delete the tracking cookie (specifically, the `hubspotutk` cookie) in order to ‘reset’ a visitor’s identity. This would allow a new `hubspotutk` cookie to be placed, essentially creating a new identity separate from the previous one.

---

<div class="post-metadata">

**Author:** ![cras6](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cras6/32/22074_2.png) [@cras6](https://community.hubspot.com/u/cras6)\
**Post date:** [February 11, 2018, 9:49pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/3 "2018-02-11T21:49:31Z")

</div>

Thank you very much for the reply.

---

<div class="post-metadata">

**Author:** ![mzebib68](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mzebib68/32/100717_2.png) [@mzebib68](https://community.hubspot.com/u/mzebib68)\
**Post date:** [June 15, 2018, 10:22am UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/4 "2018-06-15T10:22:11Z")

</div>

Derek\_Gervais:

> `hubspotutk`

Is is possible for you to share the code you used to reset this cookie?  
thanks

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [June 19, 2018, 8:20pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/5 "2018-06-19T20:20:48Z")

</div>

Hi [@mzerbib](https://community.hubspot.com/u/mzerbib),

You can do something like this:

```auto
document.getElementById("delete_hutk").onclick = function() {
 document.cookie = 'hubspotutk=;Path=/;Domain=.your_domain.com;expires=Thu, 01 Jan 1970 00:00:01 GMT;';

```

[stackoverflow.com](https://stackoverflow.com/questions/10593013/delete-cookie-by-name) [  
  ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/6/8/68ba7aa7613bc1557cd117c4d3826a1fb47be44a.png)  
 ](https://stackoverflow.com/users/603986/charlie)

#### 

[Delete cookie by name?](https://stackoverflow.com/questions/10593013/delete-cookie-by-name)

**javascript, cookies**

asked by [  
Charlie  
 ](https://stackoverflow.com/users/603986/charlie) on [01:16AM - 15 May 12](https://stackoverflow.com/questions/10593013/delete-cookie-by-name)

---

<div class="post-metadata">

**Author:** ![bensoutendijk](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bensoutendijk/32/99678_2.png) [@bensoutendijk](https://community.hubspot.com/u/bensoutendijk)\
**Post date:** [August 14, 2020, 7:42pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/6 "2020-08-14T19:42:11Z")

</div>

I am not able to successfully stop HubSpot from identifying the same user when I clear the cookie.

If I clear the cookie with the code you suggested, or if I delete the cookie manually via dev tools, the cookie is generated on the next pageview with the same exact GUID.

How do I make HubSpot generate a “new” cookie?

---

<div class="post-metadata">

**Author:** ![matt\_scott](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/matt_scott/32/36038_2.png) [@matt\_scott](https://community.hubspot.com/u/matt_scott)\
**Post date:** [March 3, 2021, 2:05pm UTC](https://community.hubspot.com/t/reset-identity-via-js-api/11519/7 "2021-03-03T14:05:23Z")

</div>

I had to also reset the \_\_hstc cookie  
Depending on what you need you can also reset session cookies (see Analytics Cookies on this page [Cookies set in your visitor's browser by HubSpot](https://knowledge.hubspot.com/reports/what-cookies-does-hubspot-set-in-a-visitor-s-browser))

```lia-code-sample
document.cookie = 'hubspotutk=;Path=/;Domain=.your-domain.com;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
document.cookie = '__hstc=;Path=/;Domain=.your-domain.com;expires=Thu, 01 Jan 1970 00:00:01 GMT;';

```
