APIs & Integrations

cras6
Participante

Reset identity via js api

resolver

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.

1 Solução aceita
Derek_Gervais
Solução
Alunos da HubSpot
Alunos da HubSpot

Reset identity via js api

resolver

Hi @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.

Exibir solução no post original

0 Avaliação positiva
6 Respostas 6
matt_scott
Top colaborador(a) | Parceiro Platinum
Top colaborador(a) | Parceiro Platinum

Reset identity via js api

resolver

 

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 https://knowledge.hubspot.com/reports/what-cookies-does-hubspot-set-in-a-visitor-s-browser)

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;';

 

Matthew Scott
Head of Development | Hubspot Solutions Architect

B2B marketing agency: Specialist B2B content marketing and demand generation for SaaS vendors and HubSpot Users | Deeply Digital | HubSpot Partner since 2010


01926 334003

deeplydigital.co.uk

3 Morton Street, Leamington Spa, CV32 5SY, UK
Derek_Gervais
Alunos da HubSpot
Alunos da HubSpot

Reset identity via js api

resolver

Hi @mzerbib,

You can do something like this:

document.getElementById("delete_hutk").onclick = function() {
            document.cookie = 'hubspotutk=;Path=/;Domain=.your_domain.com;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
0 Avaliação positiva
bensoutendijk
Membro

Reset identity via js api

resolver

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?

mzebib68
Top colaborador(a)

Reset identity via js api

resolver

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

0 Avaliação positiva
cras6
Participante

Reset identity via js api

resolver

Thank you very much for the reply.

Derek_Gervais
Solução
Alunos da HubSpot
Alunos da HubSpot

Reset identity via js api

resolver

Hi @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.

0 Avaliação positiva