This page describes user events for Agentspace apps, including user event types, requirements, and examples for user event types.
If you use the Agentspace APIs in your own apps, you need to configure search in your app to get the user events and then add the user events data to your Agentspace app.
If you create your app through the Google Cloud console, then you don't need to manually import user events (and you don't need to read this page).
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. |
search |
Searches data in the Agentspace app. |
For details about the user event object, see the
UserEvent
API reference documentation.
User event type examples and schemas
This section provides the data formats for each event type supported by Agentspace apps. 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.
view-item
The following shows the view-item
user event data format.
Minimum required view-item object
The following examples show only the required fields of the view-item
user event format.
In most cases, documents
contains details for the associated document.
JavaScript Pixel
var user_event = { "eventType": "view-item", "userPseudoId": "user-pseudo-id", "eventTime": "2020-01-01T03:33:33.000001Z", "documents": [{ "id": "document-id" }] };
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": "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", "type": "STRING", "mode": "NULLABLE" }, { "name": "uri", "type": "STRING", "mode": "NULLABLE" }, { "name": "referrerUri", "type": "STRING", "mode": "NULLABLE" } ] }, { "name": "attributionToken", "type": "STRING", "mode": "NULLABLE" }, { "name": "documents", "type": "RECORD", "mode": "REPEATED", "fields": [ { "name": "id", "type": "STRING", "mode": "NULLABLE" } ] }, { "name": "tagIds", "type": "STRING", "mode": "REPEATED" }, { "name": "attributes", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "example_text_attribute", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "text", "type": "STRING", "mode": "REPEATED" } ] }, { "name": "example_number_attribute", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "numbers", "type": "NUMERIC", "mode": "REPEATED" } ] } ] } ]
search
The following shows the search
user event format.
Minimum required search object
The following examples show only the required fields of the search
user event
format.
searchQuery
for search events where the user entered a text query.
The attributionToken
is returned with the search query results.
documents
should include the list of document IDs shown to the end user in
the search results page.
JavaScript Pixel
var user_event = { eventType: "search", userPseudoId: "user-pseudo-id", eventTime: "2020-01-01T03:33:33.000001Z", searchInfo: { searchQuery: "search-query", }, attributionToken: "attribution-token", documents: [ { id: "document-id1", }, { id: "document-id2", }, ] };
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": "eventTime", "type": "STRING", "mode": "REQUIRED" }, { "name": "searchInfo", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "searchQuery", "type": "STRING", "mode": "NULLABLE" } ] }, { "name": "pageInfo", "type": "RECORD", "mode": "NULLABLE", "fields": [ { "name": "pageCategory", "type": "STRING", "mode": "NULLABLE" } ] }, { "name": "attributionToken", "type": "STRING", "mode": "NULLABLE" }, { "name": "documents", "type": "RECORD", "mode": "REPEATED", "fields": [ { "name": "id", "type": "STRING", "mode": "NULLABLE" } ] } ]
About user information
userPseudoId
represents the unique user identifier and is required when you
record a user event.
The user information (UserInfo
) included when you record a user
event contains the userPseudoId
value and, if available, the userId
value.
userId
is optional and can be used as a unique, persistent identifier for a
user across devices whenever a user logs in to your site. When you record the
userId
for a user,
Agentspace apps
can generate more personalized results for one user across multiple devices,
such as both a mobile device and a web browser.
About the timestamp
When you record a user event, be sure to include an accurate timestamp of when
the event occurred. Accurate timestamps make sure that your events are stored in
the correct order. Timestamps are recorded automatically for events collected
using the JavaScript Pixel. When you import events, you must provide the
timestamp in the eventTime
field in the format specified by RFC
3339.