forked from MarkEdmondson1234/googleID
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata collector
72 lines (71 loc) · 2.59 KB
/
data collector
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
72
<html>
.
.
.
<body class='kaxsdc' data-event='load'>
.
.
.
<script type='text/javascript'>
var client=new ka.ClientSDK();
client.setupCallback(
{
// fires when collection has finished
'collect-end':
function(params) {
// enable login button
loginButton = document.getElementById('login_button');
loginButton.removeAttribute('disabled');
// now user can login and navigate away from the page
},
// fires when collection has started
'collect-begin':
function(params) {
// add hidden form element to post session id
var loginForm = document.forms['loginForm'];
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'kaId';
input.value = params['MercSessId'];
loginForm.appendChild(input);
}
}
);
// The auto load looks for the default, an element with the 'kaxsdc' class and
// data-event equal to a DOM event (load in this case). Data collection begins
// when that event fires on that element--immediately in this example
client.autoLoadEvents();
</script>
</body>
</html>
Alternative Integration Examples
For maximum efficiency in data collection, initiating data collection when the body loads is best. However, if your use-case demands that data collection is initiated by a different event, then this example may be helpful.
<html>
<body>
<button class='mycustomclass' data-event='click'>Click Me!</button>
<script type='text/javascript'>
var client=new ka.ClientSDK();
// notice the use of the custom class
client.className = 'mycustomclass';
client.autoLoadEvents();
</script>
</body>
</html>
Another Optional Example to use if you would rather not wait, then just call collectData()
<html>
<body>
<script type='text/javascript'>
var client=new ka.ClientSDK();
client.setupCallback(
{
// fires when collection has finished
'collect-end':
function(params) {
location.href = 'http: //example.com/loginpage';
}
}
);
client.collectData();
</script>
</body>
</html>