How to Handle Visitor IDs for Guest and Registered Users in AWS Personalize?

32 views Asked by At

I'm working on a web application and using AWS Personalize to provide customized content to both guests and registered users. I'm facing a challenge in handling visitor IDs in scenarios where a guest later logs in as a registered user.

Here's the situation:

  1. A visitor enters the site and is assigned a unique visitor ID as a guest.
  2. The visitor browses and interacts with the site, generating data linked to this guest visitor ID.
  3. Later, the visitor logs in, and we have their registered user ID.

The challenge is in handling the transition from a guest visitor ID to a registered user ID without losing the personalization data gathered during the guest session. Ideally, I want to merge or transition the data from the guest session to the registered user profile in AWS Personalize.

I am considering a solution where I could store the events from the guest user session and, upon login, send all these events tagged with the registered user ID to AWS Personalize. However, this approach might result in the duplication of events (once as a guest and then as a registered user), leading to data redundancy and potential skew in personalization results.

How can I effectively merge or transition the guest session data to the registered user's profile in AWS Personalize?

Thank you in advance for your help!

1

There are 1 answers

2
James J On BEST ANSWER

Personalize handles this for you. From the docs:

You can record events for users before they create an account. Record events for anonymous users to build a continuous event history with events from before and after they log in. This provides Amazon Personalize more interactions data about the user, which can help generate more relevant recommendations.

To record events for anonymous users (users that haven't logged in), for each event specify only a sessionId. Your application generates a unique sessionId when a user first visits your website or uses your application. You must use the same sessionId in all events throughout the session. Amazon Personalize uses the sessionId to associate events with the user before they log in.

Amazon Personalize doesn't use events from anonymous users when training until you associate them with a userId.

To provide real-time personalization for anonymous users, specify the sessionId as the userId in your GetRecommendations request.

Therefore, for anonymous users/visitors, use the visitor ID as the sessionId when calling PutEvents (excluding the userId field) AND as the userId value when calling GetRecommendations. Then, when the visitor signs in, continue to use the same visitor ID as the sessionId but this time include the userId in PutEvents. When calling GetRecommendations for identified visitors, user their durable user ID as the userId field value. Prior anonymous events will be joined to the user at the next retraining.