Scenario

To understand how usage of the Inkeep search or chat affects your business, you may want to log events from the search and chat widgets to your own analytics tool. This could be Mixpanel, Posthog, Amplitude, Segment or other analytics or CDP tools.

We expose all the events that we log to our own analytics suite through a callback function called logEventCallback that can be configured in the baseSettings configuration.

Below is an example of how to use logEventCallback to log events related to the chat_message_bot_response_received event to your analytics tool. You can check out the full reference of events by inspecting the InkeepCallbackEvent type in the npm package.

We recommend you only log the events and properties on the events that you find relevant.

Example

// customAnalyticsCallback.ts
import { InkeepCallbackEvent } from '@inkeep/uikit';

const customAnalyticsCallback = (event: InkeepCallbackEvent): void => {
  // Check if the event type is 'chat_message_bot_response_received'
  if (event.eventName === 'chat_message_bot_response_received') {
    const { question, responseMessage } = event.properties;

    // Log to your own analytics tool or CDP.
    console.log('Question: ', question);
    console.log('Response: ', responseMessage.content);
  }
};

export customAnalyticsCallback;

Available events

Accessible via the eventName property on the InkeepCallbackEvent type.

Event nameDescription
chat_message_submittedUser submits a chat message
chat_message_bot_response_receivedBot response to user message is received
search_query_submittedSearch query is submitted
search_query_response_receivedResponse to search query is received
search_result_clickedSearch result is clicked
chat_thumbs_up_feedback_submittedUser submits thumbs up feedback
chat_thumbs_down_feedback_submittedUser submits thumbs down feedback
chat_history_clearedChat history is cleared
chat_share_button_clickedShare button is clicked
chat_message_copiedChat message is copied
chat_code_block_copiedCode block in chat is copied
chat_response_citation_clickedCitation link is clicked
get_help_option_clickedGet help item is clicked
support_button_clickedSupport button (if configured as part of the aiAnnotationPolicies) is clicked

Common properties

The below are shared by all events.

Property nameDescription
organization_idOrganization ID
widgetLibraryVersionWidget library version
interactionTypeType of interaction. Value can be one of 'EMBEDDED_CHAT' | 'CHAT_BUTTON' | 'CUSTOM_TRIGGER' | 'SEARCH_BAR'.

User props

If provided to the React component, the below user properties are available.

Property nameDescription
userIdentificationTypeHow user is identified. Can be of values 'ANONYMOUS' | 'COOKIED' | 'ID_PROVIDED' depending on analytics configuration.
userCohortsUser cohorts
userEmailUser email

Chat properties

The below are shared by all chat events.

Property nameDescription
chatModeCurrentlySelectedCurrently selected chat mode
chatSessionIdID of shared chat session