Home > JavaScript event API documentation

Categories:


(Last Updated On: )

About This Article

The purpose of this article is to provide a comprehensive overview of JavaScript events.

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


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
Parameters:
– the message as a string

ChatMessageReceived:

Usage: called when the agent submits a text message for the visitor
Parameters:
– the agent alias as a string
– the message as a string

StartCallme:

Usage: called when the visitor starts a call-me
Parameters:
– 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'; });

Did you find this article helpful?

Not HelpfulNeeds WorkSo-soHelpfulVery Helpful (6 votes, average: 3.17 out of 5)
Loading ... Loading ...

Published January 12, 2012