Permalink
Browse files

Track plays

  • Loading branch information...
1 parent c226dfb commit 9885728ef3e010c8136cab2a1bc39f4e2586f98f @Seldaek committed Nov 21, 2012
Showing with 15 additions and 1 deletion.
  1. +12 −1 index.html
  2. +3 −0 js/split.js
View
@@ -34,6 +34,7 @@
<script src="js/energybar.js"></script>
<script src="js/utils.js"></script>
<script>
+ var _gaq = _gaq || [];
(function () {
var game = new Split(
document.getElementById('base'),
@@ -45,6 +46,16 @@
document.getElementById('ingame')
);
})();
+
+ if (document.location.href.indexOf('http://seld.be/split') === 0) {
+ _gaq.push(['_setAccount', 'UA-247313-9']);
+ _gaq.push(['_trackPageview']);
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+ }
</script>
</body>
-</html>
+</html>
View
@@ -24,6 +24,7 @@ var Split = function (node, trailsNode, energyNode, forceNode, scoreNode, messag
document.body.appendChild(this.collisionMap);
}
+ this.plays = 1;
this.setMessage('SPLIT<br/><br/><br/>You are trapped in a void.<br/>[SPACE] is your only way out.<br/>Longer presses go further.<br/><br/><br/>Press [SPACE] To Start', function () {
this.start();
});
@@ -56,6 +57,8 @@ Split.prototype.start = function () {
this.initControls();
this.tick();
+
+ _gaq.push(['_trackEvent', 'Game', 'Play', 'Split', this.plays++]);
};
Split.prototype.gameOver = function () {

0 comments on commit 9885728

Please sign in to comment.