Event Collection API: Search Event

Prev Next

The search event should be fired when a visitor makes a search for a product or content.

You can send the search event:

  • When a user performs a new search for a product or content.

  • When the user changes the sorting option on search results.

  • When the user applies or removes a filter (facet) to the search results.

  • When the user navigates to a different page (pagination).

You decide when a search action is complete on your client side. This could be triggered by a filter change, product click, query deletion, or any other user interaction you define.

Endpoint

POST https://eurekaevent.api.useinsider.com/api/v1/events

Visit our Postman collection to test this request.

Payload Fields

The search event supports the following properties:

Attribute Name

Type

Validation

Default

Description

eventType

String

required, equals=search

-

Type of event

source

String

oneof=

- search-popup

- search-listing

search-listing

Component where the search engine is used

query

String

required, non_blank_string

-

Query the user searched with

userId

String

required, excludes_space

Default

Unique identifier of the user. Provide this for user-based calculations

platform

String

required, oneof: desktop-web, mobile-web, tablet-web, ios, android, other

-

Platform used by the user

integrationType

String

required, oneof: api, web, sdk, app

-

Type of integration. For API integrations, send "api"

traceId

String

required, excludes_space

-

Unique trace identifier created for the current query. Use this as the primary identifier

searchSessionId

String

excludes_space

-

Deprecated. Use traceId instead. If provided, falls back bidirectionally with traceId. Kept for backward compatibility

sorting

String

Required

Relevancy

Sorting method used in search request

resultCount

Integer

required unless no result, min=1

-

Number of search results returned

itemsPerPage

Integer

required unless no result, min=1

-

Number of items per page used in search request

totalPages

Integer

required unless no result, min=1

-

Total number of pages returned by search

currentPage

Integer

required unless no result, min=1

-

Page number where the search results are displayed

products

list of product

required unless no result

-

List of products returned by the search

referrer

String

required, url

-

Source URL of the referring page

createdAt

String

RFC 3339

If omitted or invalid, defaults to the current time

Time when the event is created

campId

Integer

-

999999

A unique identifier assigned to a campaign

variationId

Integer

-

999999

A unique identifier assigned to a specific variation within a campaign

sessionId

String

-

-

Browser/app session identifier

strategyId

String

-

-

Optional strategy identifier

facets

List of facets

-

-

List of facets of the search. Required if any facet selected

Refer to Common Properties for further details.

Source Fallback:

If a source value other than search-popup or search-listing is provided, the API automatically maps it to search-listing.

TraceId Fallback:

If traceId is provided but searchSessionId is empty, searchSessionId is automatically set to the traceId value (and vice versa).

Search Product Fields

Each product object in the products array:

Parameter

Data Type

Validation

Default

Description

id

String

Required

-

Unique product identifier (catalog ID)

groupCode

String

-

-

Unique group code for the product. Without it, group-level analytics cannot be calculated

price

Double

Required

Price of the product

convertedPrice

Double

-

If not provided, price is used

Converted price of the product in your preferred currency

currency

String

Required

-

Currency of the price (ISO 4217)

preferredCurrency

String

-

If not specified, currency is used

The main currency of your site

position

Integer

-

-

Legacy position field. Used as fallback if neither searchPosition nor displayPosition is set.

searchPosition

Integer

-

-

Legacy position field. Used as fallback if neither searchPosition nor displayPosition is set.

displayPosition

Integer

required, min=1

-

Position of the product on the current page when first displayed. Falls back to searchPosition chain if not set.

isMerchandisedItem

Boolean

-

false

Indicates whether the product is a merchandised (promoted/pinned) item.

Product Deduplication Rule

For the same traceId, a product must be sent only once. Even if the user interacts with sorting, pagination, or facet filters, the same product should not be sent again within the same session. Sending the product once under the same traceId is sufficient.

Example Conceptual Flow

1. User submits a search query

  • Example: query = "queryA"

  • Generated traceId = "x123" for this search session.

2. First response is returned

  • Products: productA, productB, productC

  • Tracking layer checks: "Have I already sent productA, productB, or productC for traceId = x123?"

  • Initially, nothing has been sent yet, so: Send productA, productB, productC

  • Mark them as seen for x123.

3. User changes sorting / goes to next page / applies a filter

  • Under the same traceId = x123.

  • Some products may repeat, and some may be new (e.g., productD, productE).

  • Before sending events, filter out already-seen products.

  • Compare the new product list with the set {productA, productB, productC} already sent for x123.

  • Only send tracking events for products not in that set.

Search Event Collection Possible Scenarios

  • If a user clicks on a product, send the search event if it hasn't been sent yet.

  • On exit intent, if the search event hasn't been sent yet, send it.

  • When a product is added to the cart, if the search event hasn't been sent yet, send it.

  • If the user deletes the entire query, send the search event for the previous query if it has not already been sent.

  • If the user copies and pastes a new query, send the search event for the previous query if it has not already been sent.

  • If the user changes the query after a facet interaction, send the search event for the previous query if it has not already been sent.

Sample Request

In the example below, you see a sample request along with guidance on modifying the necessary fields. This will help you seamlessly integrate and make the most of the provided configuration.

Before usage, modifying the values such as x-auth-token and x-partner-config-key is essential.

curl --location --request POST 'https://eurekaevent.api.useinsider.com/api/v1/events' \
--header 'x-auth-token: YOUR_AUTH_TOKEN' \
--header 'x-partner-config-key: YOUR_PARTNERID-YOUR_LOCALE' \
--header 'Content-Type: application/json' \
--data-raw '{
  "referrer": "https://example.com/homepage",
  "source": "search-listing",
  "userId": "user-12345",
  "platform": "desktop-web",
  "campId": 999999,
  "variationId": 999999,
  "query": "queryA",
  "traceId": "search-traceId-abc123",
  "strategyId": "strategy-id-123",
  "sessionId": "session-id-123",
  "resultCount": 25,
  "itemsPerPage": 10,
  "totalPages": 3,
  "currentPage": 1,
  "sorting": "Relevancy",
  "facets": [
    {
      "label": "Price",
      "field": "price_en",
      "values": ["500", "2000"]
    },
    {
      "label": "Brand",
      "field": "brand_en",
      "values": ["brandA", "brandB", "brandC"]
    }
  ],
  "products": [
    {
      "id": "product-001",
      "groupCode": "group-1",
      "price": 1299.99,
      "convertedPrice": 1199.99,
      "currency": "USD",
      "preferredCurrency": "EUR",
      "displayPosition": 1
    },
    {
      "id": "product-002",
      "groupCode": "group-2",
      "price": 899.99,
      "convertedPrice": 829.99,
      "currency": "USD",
      "preferredCurrency": "EUR",
      "displayPosition": 2
    }
  ],
  "eventType": "search",
  "integrationType": "api",
  "createdAt": "2025-11-25T10:30:00Z"
}'

Sample Request (No Results)

curl --location --request POST 'https://eurekaevent.api.useinsider.com/api/v1/events' \
--header 'x-auth-token: YOUR_AUTH_TOKEN' \
--header 'x-partner-config-key: YOUR_PARTNERID-YOUR_LOCALE' \
--header 'Content-Type: application/json' \
--data-raw '{
  "referrer": "https://example.com/search",
  "source": "search-listing",
  "userId": "user-12345",
  "platform": "desktop-web",
  "query": "xyznonexistent",
  "traceId": "search-traceId-def456",
  "sorting": "Relevancy",
  "resultCount": 0,
  "eventType": "search",
  "integrationType": "api",
  "createdAt": "2025-11-25T10:31:00Z"
}'