Are logged-in Shopify customers identified automatically or do I call identify myself?
Wiring Croct into a Hydrogen store that uses Shopify customer accounts. Simple question first: if a customer is logged in, does their identity flow through to Croct automatically, or do I need to call identify somewhere in the login flow?
Then the edge cases. What happens on logout, does the profile stay attached to the browser? Guest checkout, is that just an anonymous session? And the awkward one, a shared family iPad where two different accounts log in and out of the same browser. Want to make sure we dont end up personalizing for the wrong person.
cheers
1 answer
No manual call needed for the happy path. With Shopify customer accounts, logged-in customers are identified on every request, the Hydrogen SDK picks the identity up from the session automatically. Identity resolution then links the anonymous journey to the identified profile, so nothing the visitor did before logging in is lost.
Your edge cases:
- Logout: the automatic path follows the Shopify session, so once the customer session ends the requests stop carrying that identity. If you have an explicit logout flow and want to be strict about it, croct.anonymize() exists exactly for that, it detaches the user and starts a fresh anonymous context.
- Guest checkout: yes, that stays an anonymous session unless the visitor logs in. The events still flow, they are just attached to the anonymous profile.
- Shared iPad: this is the main reason to call croct.anonymize() on logout. Each login is identified per request, so account B gets identified as account B once they sign in, but anonymizing on logout keeps the in-between anonymous browsing from being ambiguous.
Perfect, added anonymize to the logout action and left the rest automatic. cheers