collect method
Writes a single user event from the browser.
This uses a GET request to due to browser restriction of POST-ing to a 3rd party domain. This method is used only by the Retail API JavaScript pixel and Google Tag Manager. Users should not call this method directly.
Request parameters:
parent
- Required. The parent catalog name, such as
projects/1234/locations/global/catalogs/default_catalog
.
Value must have pattern
^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+$
.
ets
- The event timestamp in milliseconds. This prevents browser caching
of otherwise identical get requests. The name is abbreviated to reduce the
payload bytes.
prebuiltRule
- The prebuilt rule name that can convert a specific type
of raw_json. For example: "ga4_bq" rule for the GA4 user event schema.
rawJson
- An arbitrary serialized JSON string that contains necessary
information that can comprise a user event. When this field is specified,
the user_event field will be ignored. Note: line-delimited JSON is not
supported, a single JSON only.
uri
- 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.
userEvent
- Required. URL encoded UserEvent proto with a length limit of
2,000,000 characters.
$fields
- Selector specifying which fields to include in a partial
response.
Completes with a GoogleApiHttpBody.
Completes with a commons.ApiRequestError if the API endpoint returned an error.
If the used http.Client
completes with an error when making a REST call,
this method will complete with the same error.
Implementation
async.Future<GoogleApiHttpBody> collect(
core.String parent, {
core.String? ets,
core.String? prebuiltRule,
core.String? rawJson,
core.String? uri,
core.String? userEvent,
core.String? $fields,
}) async {
final queryParams_ = <core.String, core.List<core.String>>{
if (ets != null) 'ets': [ets],
if (prebuiltRule != null) 'prebuiltRule': [prebuiltRule],
if (rawJson != null) 'rawJson': [rawJson],
if (uri != null) 'uri': [uri],
if (userEvent != null) 'userEvent': [userEvent],
if ($fields != null) 'fields': [$fields],
};
final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/userEvents:collect';
final response_ = await _requester.request(
url_,
'GET',
queryParams: queryParams_,
);
return GoogleApiHttpBody.fromJson(
response_ as core.Map<core.String, core.dynamic>);
}