<html>
<head>
<script type='text/javascript'>
//some default pre init
var Countly = Countly || {};
Countly.q = Countly.q || [];
//provide countly initialization parameters
Countly.app_key = "YOUR_APP_KEY";
Countly.url = "https://try.count.ly"; //your server goes here
Countly.debug = true;
//start pushing function calls to queue
//track sessions automatically
Countly.q.push(['track_sessions']);
//track sessions automatically
Countly.q.push(['track_pageview']);
//load countly script asynchronously
(function() {
var cly = document.createElement('script'); cly.type = 'text/javascript';
cly.async = true;
//enter url of script here
cly.src = '../lib/countly.js';
cly.onload = function(){Countly.init()};
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(cly, s);
})();
</script>
</head>
<body>
<script type='text/javascript'>
//send event on button click
function clickEvent(ob){
Countly.q.push(['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>
|