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/widgets';

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

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

export customAnalyticsCallback;

Available events

Accessible via the event_name 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
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

Common properties

The below are shared by all events.

Property nameDescription
organization_idOrganization ID
integration_idIntegration ID
widget_library_versionWidget library version
interaction_typeType of interaction. Value can be one of 'EMBEDDED_CHAT' | 'CHAT_BUTTON' | 'CUSTOM_TRIGGER' | 'SEARCH_BAR'.
productProduct associated with interaction, if provided to the React component.

User props

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

Property nameDescription
user_identification_typeHow user is identified. Can be of values 'ANONYMOUS' | 'COOKIED' | 'ID_PROVIDED' depending on analytics configuration.
user_cohortsUser cohorts
user_emailUser email

Chat properties

The below are shared by all chat events.

Property nameDescription
chat_mode_currently_selectedCurrently selected chat mode
chat_session_idID of shared chat session