Search
Log a search event
To capture the diversity of use cases our customer base, we allow several different types of search events to be communicated.
Event | Meaning |
---|---|
search_submit | user submitted a search query |
search_result_load | search result page was loaded |
search_result_click | user clicked a product on search results page |
To log an event make a POST
request to:
POST https://ac.cnstrc.com/v2/behavioral_action/<event_type>
where event_type
is one of search_submit
, search_result_load
, search_result_click
.
Requests have to also include query string parameters
and body of the request has to have JSON object with the necessary fields, depending on event type (documented below).
Example
- Shell
- JavaScript
- Python
- Java
- iOS
- Android
- C#
Log an event
curl -X POST -H 'Content-Type: application/json' \
-u '[your token]:' \
"https://ac.cnstrc.com/v2/behavioral_action/search_submit? \
section=<section used> \
&key=<your API key> \
&c=<client id> \
&i=<user id> \
&s=<session number>" \
-d '{
"user_input": "bik",
"search_term": "bikini"
}'
// This method is not currently supported.
# This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
// This method is not currently supported.
info
The above command returns a 204 Success response on success.
Query String Parameters
Parameter | Type | Required? | Description |
---|---|---|---|
key | string | Yes | The key of the index you'd like to log events for. |
c | string | Yes | Client id. The library responsible for making the request |
i | string | Yes | User's device id. An anonymized user identification hash. |
s | integer | Yes | Session number. The counter for the session in which the behavior event occurred. We recommend to increment the session number every 30 minutes |
ui | string | No | Your internal ID for a user (if available) |
_dt | integer | No | Unix timestamp in seconds of when the event happened |
us | array of strings | No | User segment |
section | string | No | Your autosuggest and search results can have multiple sections like "Products" and "Search Suggestions". This indicates which section was searched. See your dashboard for the section names to use. |
origin_referrer | string | No | The url where the event originated. |
JSON Parameters
Search submit
Parameter | Type | Required? | Description |
---|---|---|---|
user_input | string | Yes | The text that a user had typed at the moment when submitting search request |
search_term | string | Yes | The search query, it can be different from user_input if user selected search suggestion before fully typing their query |
filters | object | No | Object that can only contain group_id key. Should be present when user selects a search suggestion that automatically applies a group_id filter |
Search result load
Parameter | Type | Required? | Description |
---|---|---|---|
search_term | string | Yes | The search query |
url | string | Yes | URL of the search results page |
result_count | integer | No | Total number of search results |
result_page | integer | No | Current page of search results |
result_id | string | No | result_id returned by Krestor search response |
items | array of objects | No | Items that were loaded. Up to 100 items, each object has to include either item_id or item_name keys, and optionally can include variation_id . All values are strings. |
selected_filters | object | No | Filters that the user had selected on the search results page. Object with string keys and values |
sort_by | string | No | The field that the user had sorted by |
sort_order | string | No | The order of sorting. One of descending or ascending |
Search result click
Parameter | Type | Required? | Description |
---|---|---|---|
search_term | string | No | User's search term. |
item_id | string | No | ID of the item that was clicked (either it or item_name is required) |
item_name | string | No | Name of the item that was clicked (either it or item_id is required) |
variation_id | string | No | ID of the variation that was shown to the user when the result was clicked |
section | string | No | Your autosuggest and search results can have multiple sections like "Products" and "Search Suggestions". This indicates which section was searched. See your dashboard for the section names to use. |
result_count | integer | No | Total number of search results |
result_page | integer | No | Current page of search results |
result_id | string | No | result_id returned by Krestor search response |
result_position_on_page | integer | No | Position of the result that was clicked relative to the current page |
num_results_per_page | integer | No | Number of results on the current page |
selected_filters | object | No | Filters that the user had selected on the search results page. Object with string keys and values |