Skip to main content

Autocomplete

Log an autocomplete event

To capture the diversity of use cases our customer base, we allow several different types of autocomplete events to be communicated.

EventMeaning
focususer focused on the autocomplete box
bluruser moved away from the autocomplete box
autocomplete_selectuser selected autocomplete suggestion

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 focus, blur, autocomplete_select. 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

Log an event
curl -X POST -H 'Content-Type: application/json' \
-u '[your token]:' \
"https://ac.cnstrc.com/v2/behavioral_action/focus? \
section=<section used for autocomplete> \
&key=<your API key> \
&c=<client id> \
&i=<user id> \
&s=<session number>" \
-d '{"user_input": "gear"}'
info

The above command returns a 204 Success response on success.

Query String Parameters

ParameterTypeRequired?Description
keystringYesThe key of the index you'd like to log events for.
cstringYesClient id. The library responsible for making the request
istringYesUser's device id. An anonymized user identification hash.
sintegerYesSession number. The counter for the session in which the behavior event occurred. We recommend to increment the session number every 30 minutes
uistringNoYour internal ID for a user (if available)
_dtintegerNoUnix timestamp in seconds of when the event happened
usarray of stringsNoUser segment
sectionstringNoYour 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_referrerstringNoThe url where the event originated.

JSON Parameters

Focus

ParameterTypeRequired?Description
user_inputstringYesThe text that a user had typed at the moment when they focused on autocomplete box

Blur

ParameterTypeRequired?Description
user_inputstringYesThe text that a user had typed at the moment when they moved away from autocomplete box

Autocomplete select

ParameterTypeRequired?Description
user_inputstringYesThe text that a user had typed at the moment when submitting search request
trstringYesAction that triggered the selection, one of click, tab, enter, valid-input
item_idstringNoID of the item that was selected (either it or item_name is required)
item_namestringNoName of the item that was selected (either it or item_id is required)
variation_idstringNoID of the variation that was shown to the user when the result was selected
group_idstringNoShould be present when user selects a search suggestion that automatically applies a group_id filter