Steersman Odoo website chat event tracking

Chat event tracking

Capturing tracking events

Steersman Odoo chat emits browser events for integration with tracking and analytics services. All events supply at least two values: channel_id and event; some events provide more details. A listener for a single event can be configured as such:

// The name of this function doesn't matter, make sure it's unique
// and correctly used in the document event listener on the last line
function myChatGreetingClickEventHandler(event)
{
    // fire a GA4 event
    gtag('event', 'start_chat', {
        'event_category': 'chat',
        'event_label': 'start',
        'value': event.detail.channel_id, // Odoo chat channel ID
    });
    // push to GTM dataLayer
    dataLayer.push({
        'event': 'start_chat',
        'channelId': event.detail.channel_id, // Odoo chat channel ID
    });
}
document.addEventListener('sbs_chat_greeting_click', myChatGreetingClickEventHandler, {passive: true});

Testing tracking events

It’s possible to setup a single event handler for all chat events for testing or capturing all events the same way:

function testSbsChatEventHandler(event)
{
    console.log('SBS Odoo Chat Event Fired', event.detail);
}

const sbsChatEvents = [
    'header_button_click',
    'greeting_show', 'greeting_hide', 'greeting_click',
    'window_fold_hide', 'window_fold_show',
    'session_sign_in', 'session_signed_in',
    'session_end', 'session_end_confirm', 'session_end_cancel',
    'session_feedback_rate ', 'session_feedback_send', 'session_feedback_skip',
    'session_transcript_send', 'session_transcript_skip',
    'contact_form_open', 'contact_form_send', 'contact_form_close',
];

sbsChatEvents.forEach(
    name => document.addEventListener(`sbs_chat_${name}`, testSbsChatEventHandler, {passive: true})
);

List of events and event detail values

  • Chat header/tab/bar button
    • sbs_chat_header_button_click
      • message — header bar text.
  • Chat greeting
    • sbs_chat_greeting_show — automatic greeting popped up.
      • operator_id — ID of the operator displayed on the greeting.
      • message — greeting message.
      • cta — button call to action text.
    • sbs_chat_greeting_hide — visitor closed the automatic greeting.
      • operator_id
      • message
      • cta
    • sbs_chat_greeting_click — visitor clicked the greeting action button to proceed.
      • operator_id
      • message
      • cta
  • Chat window
    • sbs_chat_window_fold_hide — chat window folded down.
    • sbs_chat_window_fold_show — chat window unfolded.
  • Chat session
    • sbs_chat_session_sign_in — visitor clicked “Start Chatting” on the sign-in prompt, chat session hasn’t started yet.
    • sbs_chat_session_signed_in — visitor clicked “Start Chatting” on the sign-in prompt, chat session started.
    • sbs_chat_session_end — chat session end was initiated.
      • closed_by_agent — “true” if session was ended by a chat operator.
    • sbs_chat_session_end_confirm — visitor confirmed chat session end.
    • sbs_chat_session_end_cancel — visitor cancelled chat session end.
    • sbs_chat_session_feedback_rate — visitor rated the chat experience.
      • value — rating value.
    • sbs_chat_session_feedback_send — visitor provided additional chat session feedback.
    • sbs_chat_session_feedback_skip — visitor skipped chat rating and/or additional feedback.
    • sbs_chat_session_transcript_send — visitor requested chat transcript to be emailed.
    • sbs_chat_session_transcript_skip — visitor skipped chat transcript.
  • Contact form
    • sbs_chat_contact_form_open — visitor opened the contact form while all chat operators were offline.
    • sbs_chat_contact_form_send — visitor filled out and submitted the contact form.
    • sbs_chat_contact_form_close — visitor closed the contact form.