Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SearchIOAnalytics

SearchIOAnalytics is a utility class for tracking and sending Search.io events. Event data is persisted to localStorage before being sent to track how users use search results and/or move through an ecommerce purchase funnel.

Hierarchy

  • APIClient
    • SearchIOAnalytics

Index

Constructors

  • new SearchIOAnalytics(account: string, collection: string, endpoint?: string): SearchIOAnalytics
  • Parameters

    • account: string
    • collection: string
    • Optional endpoint: string

    Returns SearchIOAnalytics

Properties

events: Record<Value, EventState[]>
queryId?: string

Methods

  • add(queryId: string, type: string, value: Value, metadata?: Metadata): void
  • Parameters

    • queryId: string
    • type: string
    • value: Value
    • Optional metadata: Metadata

    Returns void

  • flush(): Promise<void | void[]>
  • Returns Promise<void | void[]>

  • getEvents(value: Value): EventState[]
  • Parameters

    • value: Value

    Returns EventState[]

  • getExpiry(): number
  • Returns number

  • getIdentifierForType(type: string): Identifier
  • Parameters

    • type: string

    Returns Identifier

  • purge(): void
  • Returns void

  • query(req: QueryRequest): Promise<QueryResponse>
  • Query runs a search query.

    client.query({ variables: { q: "<search query>" } })
    .then((response) => {
    // handle response
    })
    .catch(error => {
    // handle error
    })

    Parameters

    • req: QueryRequest

    Returns Promise<QueryResponse>

  • save(): void
  • Returns void

  • sendEvent(queryId: string, type: string, data: Record<string, string | Metadata>): Promise<void>
  • Parameters

    • queryId: string
    • type: string
    • data: Record<string, string | Metadata>

    Returns Promise<void>

  • setEvents(value: Value, events: EventState[]): void
  • Parameters

    • value: Value
    • events: EventState[]

    Returns void

  • track(type: string, value: Value, metadata?: Metadata): void
  • Track events against the current queryId

    Parameters

    • type: string

      name of event to track (e.g. click, add_to_cart, purchase)

    • value: Value

      unique result identifier (e.g. product sku)

    • Optional metadata: Metadata

      key/value pair of information relevant to the event

    Returns void

  • trackEvent(req: TrackEventRequest): Promise<void>
  • Parameters

    • req: TrackEventRequest

    Returns Promise<void>

  • trackForQuery(queryId: string, type: string, value: Value, metadata?: Metadata): void
  • Track events against a specific current queryId

    Parameters

    • queryId: string

      queryId that event should be tracked against

    • type: string

      name of event to track (e.g. click, add_to_cart, purchase)

    • value: Value

      unique result identifier (e.g. product sku)

    • Optional metadata: Metadata

      key/value pair of information relevant to the event

    Returns void

  • updateQueryId(queryId: string): void
  • Update the current queryId

    Parameters

    • queryId: string

      queryId that events calling track should be tracked against

    Returns void

Generated using TypeDoc