This page describes user events for media search and recommendations apps, including user event types, requirements, and examples for user event types. User events are required for media apps.
For general information about media search and recommendations, see [Introduction to media search and recommendations][about-media].
For help with recording user events, see [Record real-time user events][record-events]. To import past user events in bulk, see [Import historical user events][import-user-events].
User event types
You can record the following types of user events as end users browse or search your site:
| User event name | User action |
|---|---|
view-item |
Views details of a document. |
view-home-page |
Views home page. |
search |
Searches the app. |
media-play |
Clicks play on a media item. |
media-complete |
Stops playing a media item, signifying the end of watching. |
For details about the user event object, see the
[UserEvent API reference documentation][user-event].
Event requirements for media search and recommendations
The types of user events that you need is determined by whether your app is a search app or a recommendations app, by the objective (click-through rate, conversion rate, or watch duration), and, for recommendations apps only, by the type of model that you've chosen. For more information about recommendation model types and optimization objectives, see [About media app recommendations types][rec-type-reqs].
To determine which user events you need to collect, refer to the following table.
| Event | search |
view-home-page |
view-item |
media-play |
media-complete |
||
|---|---|---|---|---|---|---|---|
| Search use case | |||||||
| Required | Not required |
Required | Required | Required | |||
| Recommended for You model type, by objective | |||||||
| CTR | Not required |
Required for homepage context Not required for general context |
Either view-item or media-play is
required |
Strongly recommended Required if history demotion is turned on |
|||
| CVR | Not required |
Required for homepage context Not required for general context |
Either view-item or media-play is
required |
Required | |||
| Watch duration | Not required |
Required for homepage context Not required for general context |
Either view-item or media-play is
required |
Required | |||
| Others You May Like model type, by objective | |||||||
| CTR | Not required |
Not required |
Either view-item or media-play is
required |
Strongly recommended Required if history demotion is turned on |
|||
| CVR | Not required |
Not required |
Either view-item or media-play is
required |
Required | |||
| Watch duration | Not required |
Not required |
Either view-item or media-play is
required |
Required | |||
| More Like This model type, by objective | |||||||
| CTR | Not required |
Not required |
Either view-item or media-play is
required |
Required if history demotion is turned on | |||
| CVR | Not required |
Not required |
Either view-item or media-play is
required |
Required | |||
| Watch duration | Not required |
Not required |
Either view-item or media-play is
required |
Required | |||
| Most Popular model type, by objective | |||||||
| CTR | Not required |
Not required |
One of view-item or media-play is
required |
Not required |
|||
| CVR | Not required |
Not required |
Not required |
Not required |
Required | ||
Requirements for media user events
Make sure your user events meet the following requirements so that your media apps can generate quality results.
| Event type | Requirement | Impact |
|---|---|---|
| All events |
Don't include synthetic data or duplicate events. |
Synthetic or duplicate events negatively impact result quality and can prevent you from deploying your app. Duplicate events can cause incorrect metrics values. |
|
Include at least 100 unique user pseudo IDs for each type of event ingested. |
Include these IDs so that media recommendations apps have enough data to generate quality results. |
|
|
User pseudo IDs must be formatted exactly the same across event import or event recording and in media recommendations requests. |
Using a consistent format for user pseudo IDs helps media recommendations apps correctly identify visitor patterns and provide better-quality results based on user behavior. |
|
|
The |
An event that includes a document without a
|
|
|
Documents included in the events should exist in your data store. |
The unjoined events ratio should be kept as low as possible. A high ratio can negatively impact the quality of results. |
|
|
Some user events should have the same user pseudo ID. |
To construct valid behavior sequence histories, media recommendations apps must be able to see multiple events with the same user pseudo ID.
For example, |
|
view-item |
Include exactly one document per event. |
The event can't be used if no document exists. If multiple documents are included, the event is malformed and can't be used. |
search |
Include the |
The |
media-play |
Include exactly one document per event. |
If multiple documents are included, the event is malformed and can't be used. |
User event tags for A/B tests
If you do A/B testing, make sure to add tag IDs to all the user events that you collect, adding one tag for each test group.
For example, add the tag "tagIds": ["original"] to the user events from your
current model and add the tag "tagIds": ["google"] to the user events from
Agent Search for media.
User event type examples and schemas
This section provides the data formats for each event type supported by media recommendations. Examples for JavaScript Pixel are provided. For BigQuery, the full table schema for each type is provided.
For all user events types, userId is optional.
For more details about the user event object, see the
[UserEvent API reference documentation][user-event].
view-item
The following shows the view-item user event data format.
Search optimization requirements for view-item events
To let search automatically optimize the search experience based on overall user trends, upload the following data.
Events should be uploaded at least daily with a maximum delay of 24 hours.
| Events metric | Events volume/frequency | Description |
|---|---|---|
Volume of view-item events |
250k view items |
At least 250,000 view items are required to optimize the search experience based on events ingested. |
Minimum required view-item object
The following examples show only the required fields of the view-item
user event format.
The
documents
object contains the document's ID
(id) and its resource
name (name).
- When you ingest or record user events at a data-store level, you can provide
the document's ID (
id) or resource name (name). - When you ingest or record events at a location level, you must supply the
document's resource name (
name) because it indicates a document's full path and refers to the data store where the document resides. You can provide the document's ID as an optional, additional information.
JavaScript Pixel
var user_event = {
"eventType": "view-item",
"userPseudoId": "USER_PSEUDO_ID",
"engine": "APP_ID",
"eventTime": "2020-01-01T03:33:33.000001Z",
"documents": [{
"name": "DOCUMENT_NAME"
}],
"panels": [
{
"panelId": "HOME_RFY_1",
"documents": [
{
"id": "123"
},
{
"id": "456"
}
],
"panelPosition": 1,
"totalPanels": 2
}
]
};
BigQuery
This is the complete JSON schema for this user event type. Specify this schema when creating tables for this user event type in BigQuery.
Modes for required fields are set to REQUIRED or REPEATED. Modes for
optional fields are set to NULLABLE.
Note that eventTime is required for importing events with
BigQuery. eventTime is a string with a Timestamp format.
[ { "name": "eventType", "type": "STRING", "mode": "REQUIRED" }, { "name": "userPseudoId", "type": "STRING", "mode": "REQUIRED" }, { "name": "engine", "type": "STRING", "mode": "NULLABLE" }, { "name": "eventTime", "type": "STRING", "mode": "REQUIRED" }, { "name": "userInfo", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "userId", "type": "STRING", "mode": "NULLABLE" }, { "name": "userAgent", "type": "STRING", "mode": "NULLABLE" } ] }, { "name": "pageInfo", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "pageviewId",