Try our conversational search powered by Generative AI!

Where does the Anonymous ID saved on the database when being generated and sent to the browser?


OptiDict supports the anonymous flow. I'm creating a new anonymous token using the /token/anonymous endpoint using the anonymous ID that is generated by Optimziely. Now I would like to know if that generated anonymous ID that I'm using to generate a token is saved somewhere on the database. I was able to find the anonymous ID when creating a cart with that anonymous id. However, what I would like to know if it's saved somewhere on the database before creating a cart. Specfically when the anonymous ID is being generated.

Any help is appreciated.

Feb 13, 2024 10:15

If you're talking about IAnonymousIdFeature, then it is generated in AnonymousIdMiddleware, used in middleware pipeline with app.UseAnonymousId().
The ID is generated in the middleware with Guid.NewGuid() and stored in "EPiServer_Commerce_AnonymousId" cookie, and to my understanding it's not stored in database (with default implementation).

Feb 14, 2024 8:54

No, it is not stored separately in the database. And the middleware that generates the Anonymous ID has no event to hook into. The only where it is stored, is the shopping cart.

Mar 29, 2024 15:25

But I was thinking, if you don't want to pass the anonynous id cookie (many native apps prefer not to), and instead wants to include the anonymous id in the token, then you could look into generating your own as part of the token process.

Then you could add your own middleware to unwrap the token and get the anonymous id claim. As long as it adds an implementation of IAnonymousIdFeature before the built-in middleware, then the built-in will not run.

Mar 29, 2024 15:32
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.