Recording a single item interaction event
After you create an Item interactions dataset and an event tracker for your dataset group,
you are ready to record item interaction events. The following example shows a PutEvents
operation that passes one item interaction event. The
corresponding schema is shown, along with an example row from the Item interactions dataset.
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 (is anonymous). For more information, see
Recording events for
anonymous users.
The event list is an array of Event objects. An
eventType
is required for each event. If you don't have event type data, you can provide a placeholder value to satisfy the requirement.
The trackingId
comes from the event tracker you created in Creating an item interaction event tracker. The userId
, itemId
, and sentAt
parameters
map to the USER_ID, ITEM_ID, and TIMESTAMP fields of a corresponding historical Interactions
dataset. For
more information, see Creating schema JSON files for Amazon Personalize schemas.
Corresponding dataset columns
Dataset columns: USER_ID, ITEM_ID, TIMESTAMP, EVENT_TYPE
Example data: user123, item-xyz, 1543631760, click
Code example
import boto3
personalize_events = boto3.client(service_name='personalize-events')
personalize_events.put_events(
trackingId = 'tracking_id
',
userId= 'USER_ID
',
sessionId = 'session_id
',
eventList = [{
'sentAt': 1719511760
,
'eventType': 'click
',
'itemId': 'ITEM_ID
'
}]
)