Interface IAnalyticsClient

The IAnalyticsClient interface describes an analytics client that can log events to, or return information from the usage analytics service.

See also the Analytics component.

Index

Methods

getCurrentVisitIdPromise

  • getCurrentVisitIdPromise(): Promise<string>

getOriginContext

  • getOriginContext(): string

getTopQueries

  • getTopQueries(params: ITopQueries): Promise<string[]>

getUserDisplayName

  • getUserDisplayName(): string

isActivated

  • isActivated(): boolean

logClickEvent

  • Logs a Click usage analytics event.

    A Click event corresponds to an item view (e.g., clicking on a ResultLink or opening a Quickview).

    Click events are immediately sent to the Coveo Usage Analytics service.

    Note:

    When logging custom Click events, you should use the Coveo.logClickEvent top-level function rather than calling this method directly from the analytics client. See Logging Your Own Search Events.

    Type parameters

    • TMeta

    Parameters

    • actionCause: IAnalyticsActionCause

      The cause of the event.

    • meta: TMeta

      The metadata which you want to use to create custom dimensions. Metadata can contain as many key-value pairs as you need. Each key must contain only alphanumeric characters and underscores. The Coveo Usage Analytics service automatically converts uppercase characters to lowercase characters in key names. Each value must be a simple string. You do not have to pass an IAnalyticsDocumentViewMeta as meta when logging a Click event. You can actually send any arbitrary meta. If you do not need to log metadata, you can simply pass an empty JSON ( {} ).

    • result: IQueryResult

      The result that was clicked.

    • element: HTMLElement

      The HTMLElement that the user has clicked in the interface. Default value is the element on which the Analytics component is bound.

    Returns Promise<IAPIAnalyticsEventResponse>

logCustomEvent

  • Logs a Custom usage analytics event on the service.

    You can use Custom events to create custom reports, or to track events which are neither queries (see [logSearchEvent]{@link AnalyticsClient.logSearchEvent} and [logSearchAsYouType]{@link AnalyticsClient.logSearchAsYouType}), nor item views (see [logClickEvent]{@link AnalyticsClient.logClickEvent}).

    Note:

    When logging Custom events, you should use the Coveo.logClickEvent top-level function rather than calling this method directly from the analytics client. See Logging Your Own Search Events.

    Type parameters

    • TMeta

    Parameters

    • actionCause: IAnalyticsActionCause

      The cause of the event.

    • meta: TMeta

      The metadata which you want to use to create custom dimensions. Metadata can contain as many key-value pairs as you need. Each key must contain only alphanumeric characters and underscores. The Coveo Usage Analytics service automatically converts white spaces to underscores and uppercase characters to lowercase characters in key names. Each value must be a simple string. If you do not need to log metadata, you can simply pass an empty JSON ( {} ).

    • element: HTMLElement

      The HTMLElement that the user has interacted with for this custom event. Default value is the element on which the Analytics component is bound.

    • Optional result: IQueryResult

      The IQueryResult that the custom event is linked to, if any.

    Returns Promise<IAPIAnalyticsEventResponse>

logSearchAsYouType

  • Logs a SearchAsYouType usage analytics event.

    This method is very similar to the [logSearchEvent]{@link AnalyticsClient.logSearchEvent} method, except that logSearchAsYouType should, by definition, be called more frequently. Consequently, in order to avoid logging every single partial query, the PendingSearchAsYouTypeEvent takes care of logging only the "relevant" last event: an event that occurs after 5 seconds have elapsed without any event being logged, or an event that occurs after another part of the interface triggers a search event.

    It is important to call this method before executing the query. Otherwise, no SearchAsYouType event will be logged, and you will get a warning message in the console.

    Note:

    When logging custom SearchAsYouType events, you should use the Coveo.logSearchAsYouTypeEvent top-level function rather than calling this method directly from the analytics client. See Logging Your Own Search Events.

    Type parameters

    • TMeta

    Parameters

    • actionCause: IAnalyticsActionCause

      The cause of the event.

    • meta: TMeta

      The metadata which you want to use to create custom dimensions. Metadata can contain as many key-value pairs as you need. Each key must contain only alphanumeric characters and underscores. The Coveo Usage Analytics service automatically converts white spaces to underscores and uppercase characters to lowercase characters in key names. Each value must be a simple string. If you do not need to log metadata, you can simply pass an empty JSON ( {} ).

    Returns void

logSearchEvent

  • Logs a Search usage analytics event.

    A Search event is actually sent to the Coveo Usage Analytics service only after the query successfully returns (not immediately after calling this method). Therefore, it is important to call this method before executing the query. Otherwise, the Search event will not be logged, and you will get a warning message in the console.

    Note:

    When logging custom Search events, you should use the Coveo.logSearchEvent top-level function rather than calling this method directly from the analytics client. See Logging Your Own Search Events.

    Type parameters

    • TMeta

    Parameters

    • actionCause: IAnalyticsActionCause

      The cause of the event.

    • meta: TMeta

      The metadata you want to use to create custom dimensions. Metadata can contain as many key-value pairs as you need. Each key must contain only alphanumeric characters and underscores. The Coveo Usage Analytics service automatically converts white spaces to underscores, and uppercase characters to lowercase characters in key names. Each value must be a simple string. If you do not need to log metadata, you can simply pass an empty JSON ( {} ).

    Returns void

setOriginContext

  • setOriginContext(originContext: string): any
  • Sets the Origin Context dimension on the analytic events.

    You can use this dimension to specify the context of your application.

    Suggested values are Search, InternalSearch, or CommunitySearch.

    Default value is Search.

    Parameters

    • originContext: string

      The origin context value.

    Returns any

Hierarchy

  • IAnalyticsClient