Implement user events

To configure your user events:

  1. Import historical user events.

  2. Record live user events.

  3. Tag user events with entities.

  4. Flag user events with attribution tokens.

User information

The visitorId value represents the unique user identifier. It's required when you record a user event. (UserInfo) is included when you record a user event that has the visitorId value and, if available, the userId value.

You can use the optional userId value as a unique, persistent identifier for a user across devices whenever a user signs in to your site. When you record the userId for a user, Vertex AI Search for commerce can generate more personalized results for one user across multiple devices, such as a mobile device and web browser.

User event timestamp

When you record a user event, be sure to include an accurate timestamp of when the event occurred. Accurate timestamps ensure that events are stored in the correct order. Timestamps are recorded automatically for events collected using Tag Manager and the JavaScript Pixel. When you import events, you must provide the timestamp in the eventTime field in the format specified by RFC 3339.

Custom attributes for user events

You can include additional custom attributes and features for user events. This can result in improved, more specific recommendations for your users when you use recommendations. To add custom attributes, use attributes when you record a user event.

If you provide custom attributes for ingested user events, it's important to also include them in the user events that you associate with prediction requests. The formatting of custom attributes must be consistent between imported events and events provided with prediction requests. This enables use of those custom attributes when training models and serving predictions, which helps improve recommendation quality.

You can provide custom text values by using the text field, or custom numerical values by using the number field.

For example, the following shows the attributes section from a request to record a user event:

"attributes": {
  "user_age": {"text": ["teen", "young adult"]},
  "user_location": {"text": ["CA"]}
}

Monitor import health

Recording user events successfully is important for getting high-quality results. You should monitor the event recording error rates and take action if needed. For more information, see Setting up alerts for data upload issues.