Home > JavaScript event API documentation
Categories: JavaScript API
(Last Updated On: July 18, 2017)
*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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<pre lang=javascript>// 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