forked from Countly/countly-sdk-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_sync.html
45 lines (42 loc) · 934 Bytes
/
example_sync.html
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
<html>
<head>
<!--Countly script-->
<script type='text/javascript' src='countly.min.js'></script>
<script type='text/javascript'>
//initializing countly with params
Countly.init({
app_key: "YOUR_API_KEY",
url: "http://yourdomain.com", //or none for default countly cloud
debug:true
})
//start session on each page view
Countly.begin_session();
//add any events you want like pageView
Countly.add_event({
"key": "pageView",
"segmentation": {
"url": window.location.pathname
}
});
//end session on leaving page
window.onunload = function(){
Countly.end_session();
};
</script>
</head>
<body>
<script type='text/javascript'>
//send event on button click
function clickEvent(ob){
Countly.add_event({
key:"buttonClick",
"segmentation": {
"id": ob.id
}
});
}
</script>
<input type="button" id="testButton" onclick="clickEvent(this)" value="Test Button">
<p><a href='http://count.ly/'>Count.ly</a></p>
</body>
</html>