- [HTTP request](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.PATH_PARAMETERS)
- [Query parameters](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.QUERY_PARAMETERS)
- [Request body](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.request_body)
- [Response body](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#body.aspect)
- [Try it!](https://docs.cloud.google.com/gemini-enterprise-cx/ai-commerce-search/reference/rest/v2/projects.locations.catalogs.userEvents/collect.md.txt#try-it)

Writes a single user event from the browser.

For larger user event payload over 16 KB, the POST method should be used instead, otherwise a 400 Bad Request error is returned.

This method is used only by the AI Commerce Search API JavaScript pixel and Google Tag Manager. Users should not call this method directly.

### HTTP request

`GET https://retail.googleapis.com/v2/{parent=projects/*/locations/*/catalogs/*}/userEvents:collect`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `parent` | `string` Required. The parent catalog name, such as `projects/1234/locations/global/catalogs/default_catalog`. |

### Query parameters

| Parameters ||
|---|---|
| `userEvent` | `string` Required. URL encoded UserEvent proto with a length limit of 2,000,000 characters. |
| `uri` | `string` The URL including cgi-parameters but excluding the hash fragment with a length limit of 5,000 characters. This is often more useful than the referer URL, because many browsers only send the domain for 3rd party requests. |
| `ets` | `string (int64 format)` The event timestamp in milliseconds. This prevents browser caching of otherwise identical get requests. The name is abbreviated to reduce the payload bytes. |
| `rawJson` | `string` An arbitrary serialized JSON string that contains necessary information that can comprise a user event. When this field is specified, the userEvent field will be ignored. Note: line-delimited JSON is not supported, a single JSON only. |
| The rule that can convert the raw_json to a user event. It is needed only when the raw_json is set. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `prebuiltRule` | `string` The prebuilt rule name that can convert a specific type of rawJson. For example: "ga4_bq" rule for the GA4 user event schema. |
| End of mutually exclusive fields. ||

### Request body

The request body must be empty.

### Response body

If successful, the response is a generic HTTP response whose format is defined by the method.

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication.md.txt#authorization-gcp).