Skip to main content

Report user event API

Use the POST /v1/stats/{index_public_key} endpoint to report user search and click events to AddSearch analytics. This helps track user interactions and improve search relevance.

Endpoint

POST /v1/stats/{index_public_key}

Replace {index_public_key} with your AddSearch index's public key.

Event types

You can report two types of events:

  • Search event: when a user performs a search query
  • Click event: when a user clicks a search result

Search event payload

{
"action": "search",
"session": "session_name",
"keyword": "test query",
"numberOfResults": 4,
"tag": "optional_tag"
}

Search event parameters

ParameterDescriptionTypeNotes
actionType of user actionstringMust be exactly "search"
sessionUnique user search session identifierstringUp to 32 characters, used to group related actions
keywordSearch keywords entered by the userstringMultiple keywords separated by spaces
numberOfResultsNumber of results returned for this queryintegerZero indicates a "No hit" event in the analytics dashboard
tagOptional tag to filter analytics in dashboardstringUp to 50 characters; see analytics tags

Click event payload

{
"action": "click",
"session": "session_name",
"keyword": "test query",
"docid": "abc123",
"position": 1,
"tag": "optional_tag"
}

Click event parameters

ParameterDescriptionTypeNotes
actionType of user actionstringMust be exactly "click"
sessionUnique user search session identifierstringUp to 32 characters
keywordSearch keywords associated with the clickstringMultiple keywords separated by spaces
docidID of the clicked documentstringMD5 hash of the document's full URL including protocol and query parameters. Max length 32 characters.
positionPosition of the clicked item in search resultsintegerStarts at 1
tagOptional tag to filter analytics in dashboardstringUp to 50 characters; see analytics tags

Request details

  • Content-Type: application/json
  • Returns: HTTP 200 OK on success

Important notes

  • Searches performed through the search API endpoint are automatically reported.
  • For custom search UI implementations, set the collectAnalytics parameter to false in the search API to avoid duplicate events.
  • Instead, report search and click events explicitly using this API endpoint to ensure accurate analytics and ranking adjustments based on user behavior.

See also