All questions

On logout should I call anonymize, and does it wipe the profile I built up?

Asked by Peter Novak on

PNPeter Novak

Our Next app calls identify on login and I am now adding the logout side of the behaviour. Two things I want to get right before I ship it.

First, is croct.anonymize() the correct call on logout. Second, and this is the one that worries me, does calling it destroy the profile data we collected while the user was identified? I would rather ask than find out we threw away history.

Was this helpful?

2 answers

IBIngrid Bakker

Yes, croct.anonymize() is the correct call on logout, it mirrors the croct.identify('<userId>') you already call on login. So your instinct to pair them is right.

On the worry: it does not destroy the identified profile. Identity resolution links the anonymous and identified profiles, so switching back to anonymous on logout does not lose the data that was collected while the user was identified. The identified profile keeps its history.

Was this helpful?
Ggabor_k

to add the mechanism, the ct.user_token cookie (about 7 days) is what carries the identified session, and anonymize is what clears that side. one subtlety worth knowing so the behaviour does not surprise you later: anonymous and identified profiles are not associated with each other for sync purposes, so the next anonymous session on that browser stays its own thing rather than inheriting the logged-in identity. background on the two states in the returning vs anonymous thread.

Was this helpful?
PNPeter Novak

That settles it, anonymize on logout and the identified history is safe. The note about the next anonymous session staying separate is exactly the behaviour I wanted to confirm. Shipping it.

Still have questions?