-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathle_custom.js
71 lines (67 loc) · 2.46 KB
/
le_custom.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************ History ***********************
* LiveEngage 2.0 Customisation
* This file SHOULD be included on ALL webpages: this file contains client specific code
******************************************** */
/* ************ Chat events ****************** */
// @@dev: assuming the use of Google Analytics for Web (ga.js)
var evLPstate
lpTag.events.bind(
{
appName: 'ChatAPIV3',
eventName: 'state',
func: function (e) {
switch (e) {
case 'init': break // visitor clicked engagement offer
case 'initialised': break
case 'preChat': break // pre-chat survey shown to visitor
case 'waiting': break // waiting for available agent
case 'resume': // existing chat is resumed
evLPstate = true
break
case 'chatting': // visitor is connected to an CSP
(!evLPstate) ? _gaq.push(['_trackEvent', 'chats', 'started', undefined, undefined, false]) : undefined
break
case 'ended': // chat was ended
_gaq.push(['_trackEvent', 'chats', 'ended', undefined, undefined, false])
break
case 'postChat': // post-chat survey shown to visitor
_gaq.push(['_trackEvent', 'chats', 'postchatsurveysubmitted', undefined, undefined, false])
break
case 'applicationEnded': break // visitor submitted post-chat survey
default:
break
}
}
}
)
/* ************ Single Page Applications ***** */
var loadLPNewPage = function (pageUrl, data) {
var section, sdes
// Making sure lpTag.newPage() has all its parameters at least defined.
section = data.section || []
sdes = data.sdes || []
if (window.lpTag && window.lpTag.newPage) {
// taglets are ready
lpTag.newPage(
pageUrl,
{
section: section,
sdes: sdes
}
)
} else {
// taglets not ready; wait for LE Tag to start before executing lpTag.newPage() function
window.lpMTagConfig = window.lpMTagConfig || {}
lpMTagConfig.onLoadCode = lpMTagConfig.onLoadCode || [] // this is for listening to a special event when the LE Tag code finally starts
// push lpTag.newPage() function into the array defined above and it will be executed when LE Tag finally starts
lpMTagConfig.onLoadCode.push(function () {
lpTag.newPage(
pageUrl,
{
section: section,
sdes: sdes
}
)
})
} // end of if (window.lpTag && window.lpTag.newPage)
} // end of loadLPNewPage