Add your own analytics
Use our callback function to log events from the search and chat widgets to your own analytics tool.
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 onEvent
that can be configured in the baseSettings configuration.
Below is an example of how to use onEvent
to log events related to the assistant_message_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.
Implementation Examples
Basic Implementation
Advanced Implementation with Event Filtering
Implementation with Multiple Analytics Tools
Common Properties
Every event includes a set of common properties that provide context about the widget and the interaction. These properties are automatically included in the properties
object of every event:
Property | Type | Description |
---|---|---|
widgetLibraryVersion | string | The version of the Inkeep widget library being used |
componentType | string | The type of widget interaction. Possible values: 'ChatButton' , 'CustomTrigger' , 'SearchBar' , 'EmbeddedChat' , 'EmbeddedSearch' , 'EmbeddedSearchAndChat' , 'IntelligentForm' |
tags | string[] | Custom tags passed in the baseSettings . These can be used to categorize or filter events |
Example with Tags
User Properties
User properties are exactly what you pass to the userProperties
in baseSettings. These properties can be used to associate events with specific users or teams.
Configuration Options
Privacy Preferences
These settings are used to configure the analytics tracking for the widget; passed in the baseSettings
configuration.
Option | Type | Default | Description |
---|---|---|---|
optOutAnalyticalCookies | boolean | false | Opt out of analytical cookies |
optOutAllAnalytics | boolean | false | Opt out of all analytics tracking |
optOutFunctionalCookies | boolean | false | Opt out of functional cookies |
Events Reference
Chat Events
Event Name | Description | Properties |
---|---|---|
assistant_message_received | Assistant response received | conversation |
user_message_submitted | User message submitted | conversation |
shared_chat_loaded | Shared chat loaded | conversation |
assistant_positive_feedback_submitted | Positive feedback given | conversation , reasons |
assistant_negative_feedback_submitted | Negative feedback given | conversation , reasons |
get_help_option_clicked | Help option selected | getHelpOption , conversation |
chat_clear_button_clicked | Chat cleared | conversation |
chat_share_button_clicked | Share button clicked | sharedChatUrl , sharedConversationId , originalConversationId , conversation |
assistant_message_copied | Message copied | conversation |
assistant_code_block_copied | Code block copied | conversation , language , code |
assistant_source_item_clicked | Source item clicked | conversation , link |
assistant_message_inline_link_opened | Message link opened | title , url |
Search Events
Event Name | Description | Properties |
---|---|---|
search_result_clicked | Result clicked | searchQuery , title , url |
search_query_submitted | Query submitted | searchQuery |
search_query_response_received | Search results received | searchQuery , totalResults |
Intelligent Form Events
Event Name | Description | Properties |
---|---|---|
intelligent_form_submitted | Form submitted | conversation , values |
intelligent_form_primary_section_submitted | Primary section submitted | conversation |
intelligent_form_ai_response_provided | AI response provided | conversation , recordsConsidered |