Recording real-time events to influence recommendations - Amazon Personalize
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Recording real-time events to influence recommendations

An event is an interaction between a user and your catalog. It can be an interaction with an item, such as a user purchasing an item or watching a video, or it can be taking an action, such as applying for a credit card or enrolling in a membership program.

Amazon Personalize can make recommendations based on real-time event data only, historical event data only, or a mixture of both. Record real-time events as your customers interact with recommendations. This builds out your interactions data and keeps your data fresh. And it tells Amazon Personalize about the current interests of your user, which can improve recommendation relevance.

If your domain use case or custom recipe supports real-time personalization, Amazon Personalize uses events in real time to update and adapt recommendations according to a user's evolving interest.

How you record real-time events depends on the type of interactions data you are importing:

How real-time events influence recommendations

If your recipe supports real-time personalization, after you create a recommender or custom campaign, Amazon Personalize uses new recorded event data for existing items or actions within seconds of import. The following use cases and recipes support real-time personalization:

If you use the Trending-Now recipe, Amazon Personalize automatically considers items from new events data over configurable intervals. You don't have to create a new solution version. For more information, see Trending-Now recipe.

If the item, action, or user in the event is new, how the Amazon Personalize uses the data depends on your use case or recipe. For more information, see How new data influences real-time recommendations.

Recording events for anonymous users

Important

If you don't record at minimum one event with a sessionId and userId for a user, Amazon Personalize won't use the activity tracked to only the sessionId when training. And after training completes, recommendations will no longer be based on activity tracked to the sessionId.

You can record item interaction or action interaction 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. For more information, see Building a continuous event history for anonymous users.

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

Building a continuous event history for anonymous users

To build an event history for an anonymous user and have Amazon Personalize use their events when training, record at minimum one event with both a sessionId and a userId. Then you can record any number of events for the userId. After you start providing a userId, the sessionId can change. During the next full retraining, Amazon Personalize associates the userId with the anonymous user history tracked to the original sessionId.

After retraining completes, recommendations will be based on activity tracked to both the sessionId from the anonymous events and any events tracked to their userId.

Note

If your user doesn't create an account and you want Amazon Personalize to use the data when training, you can use the sessionId as the userId in events. However, if the user eventually creates an account, you won't be able to associate the events from their anonymous browsing with their new userId.

Third-party event tracking services

The following Customer Data Platforms (CDPs) can help you collect event data from your application and send it to Amazon Personalize.

Sample implementations

For a sample Jupyter notebook that shows how to use Amazon Personalize to react to real-time behavior of users using an event tracker and the PutEvents operation, see 2.View_Campaign_And_Interactions.ipynb in the getting_started folder of the amazon-personalize-samples GitHub repository.

For an example that shows how to stream events from users interacting with recommendations, see streaming_events in the Amazon Personalize samples GitHub repository.

For a complete example that contains the source code and supporting files to deploy real-time APIs that sit between your Amazon Personalize resources and client applications, see Real-Time Personalization APIs in the Amazon samples GitHub repository. This project includes how to implement the following:

  • User context and user event collection

  • Response caching

  • Decorating recommendations based on item metadata

  • A/B testing

  • API authentication