You can track any custom stats or events in your web app using StatHat's JavaScript library.
Just put this code in the HEAD section of an HTML document:
<script type="text/javascript">
var _StatHat = _StatHat || [];
_StatHat.push(['_setUser', 'XYXYXYXYXYXYXYXYX']);
(function() {
var sh = document.createElement('script'); sh.type = 'text/javascript';
sh.async = true;
sh.src = '//www.stathat.com/javascripts/api.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(sh, s);
})();
</script>
Since anyone can view the source of your javascript files, we recommend using the Classic API for client-side JavaScript. This means you have to create a stat with the web interface first.
After creating a stat, StatHat will show you the keys you need on the stat details page in the Code snippet section. Say your stat key is XXXXXXXXX, post the stat with this code:
<script type="text/javascript">
_StatHat.push(['_trackValue', 'XXXXXXXXXX', 3.14159]);
</script>
You can track as many custom stats as you want on a page.
© 2011-2017 Numerotron Inc