Quack SDK Tracking Documentation

Overview

The Quack SDK provides a comprehensive event tracking system that allows you to monitor user interactions and chat behavior. The tracking system is built around the trackCallback method and supports various analytics events through the Mixpanel integration.

trackCallback Method

Purpose

The trackCallback method allows you to register a custom callback function that will be invoked whenever tracking events occur within the Quack SDK.

Signature

trackCallback(callback: (eventName: string, properties: any) => void): void

Parameters

  • callback: A function that receives two parameters:

    • eventName (string): The name of the event being tracked

    • properties (object): An object containing event-specific data and metadata

Usage Example

// Set up tracking callback
window.quack.trackCallback((eventName, properties) => {
  console.log("Event tracked:", eventName, properties);

  // Send to your analytics service
  analytics.track(eventName, properties);
});

Tracked Events

Core Chat Events

1. chatbot_session_start

Triggered when a new chat session begins.

When it triggers: Fired immediately when a user initiates a new chat session, either by clicking the chat button or through proactive chat activation.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL when session started

  • chatId (string): Unique chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name (same as eventName parameter)

Implementation Example:

2. chatbot_session_created

Fired when a chat session is successfully created on the backend.

When it triggers: Occurs after the backend successfully creates and initializes a new chat session, confirming that the session is ready for messaging.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Unique chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name

Implementation Example:

3. chatbot_loaded

Triggered when the chatbot widget is fully loaded and ready.

When it triggers: Fires when the chatbot widget has completely loaded all necessary resources and is ready for user interaction.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Chat session identifier (if available)

  • isProactive (boolean): Whether this is a proactive session

  • event (string): Event name

Implementation Example:

4. chatbot_viewed

Fired when the chatbot interface becomes visible to the user.

When it triggers: Occurs when the chat interface is opened and becomes visible to the user, typically after clicking the chat button.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name

Implementation Example:

User Interaction Events

5. chat_button_clicked

Triggered when the chat toggle button is clicked.

When it triggers: Fires every time the user clicks the main chat toggle button, whether opening or closing the chat interface.

Properties:

  • tenant (string): The tenant identifier

  • opened (boolean): Whether the chat was opened (true) or closed (false)

  • chatId (string): Chat session identifier

  • isProactive (boolean): Whether this is a proactive session

  • event (string): Event name

Implementation Example:

6. user_message_sent

Fired when a user sends a message in the chat.

When it triggers: Occurs immediately after a user submits a message in the chat interface, before the bot response.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name

  • message (object): Message details

    • text (string): The message content

    • createdAt (string): Timestamp when message was created

Implementation Example:

7. bot_message_sent

Triggered when the bot sends a message to the user.

When it triggers: Fires when the chatbot or system sends a response message to the user, including automated responses and agent messages.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name

  • message (object): Message details

    • text (string): The message content

    • createdAt (string): Timestamp when message was created

Implementation Example:

8. cta_button_clicked

Fired when a call-to-action button is clicked within the chat interface.

When it triggers: Occurs when a user clicks any interactive button within chat messages, such as quick reply buttons, links, or action buttons.

Properties:

  • tenant (string): The tenant identifier

  • button_name (string): Name/identifier of the clicked button

  • chatId (string): Chat session identifier

  • isProactive (boolean): Whether session was initiated proactively

  • event (string): Event name

  • link (string): URL of the clicked link (when applicable)

Implementation Example:

Proactive Chat Events

9. chatbot_proactive

Triggered when a proactive chat session is initiated.

When it triggers: Fires when the system automatically initiates a chat session without user interaction, typically based on predefined rules or user behavior patterns.

Properties:

  • tenant (string): The tenant identifier

  • entry_page (string): Current page URL

  • chatId (string): Chat session identifier

  • isProactive (boolean): Always true for this event

  • event (string): Event name

Implementation Example:

Event Properties Reference

Common Properties

All events include these standard properties:

Property
Type
Description

tenant

string

Unique identifier for the tenant/organization

event

string

The event name (matches the eventName parameter)

chatId

string

Unique identifier for the chat session

isProactive

boolean

Indicates if the session was initiated proactively

Contextual Properties

Additional properties that may be included:

Property
Type
Description

entry_page

string

URL of the page where the event occurred

opened

boolean

Whether chat was opened (for button click events)

button_name

string

Identifier of clicked button

message

object

Message content and metadata

link

string

URL for link-related events

Implementation Details

Best Practices

  1. Always register trackCallback early: Set up your tracking callback before initializing chat sessions

  2. Handle errors gracefully: Wrap your tracking logic in try-catch blocks

  3. Respect user privacy: Ensure compliance with privacy regulations when tracking user data

  4. Filter sensitive data: Avoid logging sensitive information in message content

  5. Use consistent naming: Follow your organization's event naming conventions

  6. In development mode, tracking events are logged to the console instead of being sent to analytics services.

Example Integration

Troubleshooting

Common Issues

  1. Events not firing: Ensure trackCallback is set before chat initialization

  2. Missing properties: Check that the chat session is properly established

  3. Duplicate events: Verify that trackCallback is only set once

Debug Mode

Enable debug mode by setting localStorage.setItem("quack-debug", "true") to see additional logging information.

Last updated

Was this helpful?