Home > JavaScript event API documentation

Categories:


(Last Updated On: April 12, 2013)

*Note: Please see the updated Javascript Event Documentation here.


List of Events:

Open:
usage: called when the user opens the form on a button click, through an API call to startLink(), startChat(), etc.
parameters:
– agent online/offline with the string value ‘online’ or ‘offline’

OpenProactive: 
usage: called when the proactive chat starts
parameters:
– agent alias as a string
– proactive prompt message as a string

Close: 
usage: called when the form close button is clicked
parameters:
– what was closed: the form, a chat session in progress, or a proactive prompt not answered by the visitor with the respective string
values ‘form’/’chat’/’proactive’
– agent status online/offline with the string value ‘online’ or ‘offline’

MessageSubmit: 
usage: called when the visitor posts the form for an offline message (not a chat)
parameters:
– email address as a string
– message/question as a string

StartChat:
usage: called when the visitor starts a chat
parameters:
– email as a string
– first message as a string
– type of chat manual or proactive, as ‘manual’ or ‘proactive’

ChatMessageSent:
usage: called when the visitor submits a chat message while in the chat session
parameter:
– the message as a string

ChatMessageReceived:
usage: called when the agent submits a text message for the visitor
parameter:
– the agent alias as a string
– the message as a string

StartCallme:
usage: called when the visitor starts a call-me
parameter:
– phone number as a string

Code examples on how to use the SnapEngage JavaScript event API:

// For cookie based conversion tracking

SnapABug.setCallback('ChatMessageReceived', function(agent, msg) {
 var date = new Date();
 date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));
 document.cookie = 'chatWith=' + encodeURIComponent(agent) + '; expires=' + date.toGMTString() + '; path=/;';
 });

// For Google Analytics integration to track the proactive chat engagement rate with the agent alias tracking
 // Google Analytics Event Tracking: http://code.google.com/intl/en-US/apis/analytics/docs/tracking/eventTrackerOverview.html

var seAgent;
 SnapABug.setCallback('OpenProactive', function(agent, msg) {
 seAgent = agent;
 _gaq.push(['_trackEvent', 'SnapEngage', 'proactivePrompt', agent]);
 });

SnapABug.setCallback('StartChat', function(email, msg, type) {
 if (type == 'proactive') {
 _gaq.push(['_trackEvent', 'SnapEngage', 'proactiveEngaged', seAgent]);
 }
 });

// For Google Analytics integration to track the proactive chat engagement rate with the agent alias tracking
 // Note this is to use with the old version of Google Analtics
 // Google Analytics Event Tracking: http://code.google.com/intl/en-US/apis/analytics/docs/tracking/eventTrackerOverview.html

var seAgent;
 SnapABug.setCallback('OpenProactive', function(agent, msg) {
 seAgent = agent;
 pageTracker._trackEvent('SnapEngage', 'proactivePrompt', agent);
 });

SnapABug.setCallback('StartChat', function(email, msg, type) {
 if (type == 'proactive') {
 pageTracker._trackEvent('SnapEngage', 'proactiveEngaged', seAgent);
 }
 });

// Handler on close to redirect to the support site

SnapABug.setCallback('Close', function(type, status) {
 document.location = 'http://www.yoursite.com/support';
 }); 

Published January 12, 2012