Skip to content

Commit

Permalink
Track plays
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 22, 2012
1 parent c226dfb commit 9885728
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.html
Expand Up @@ -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'),
Expand All @@ -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>
3 changes: 3 additions & 0 deletions js/split.js
Expand Up @@ -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();
});
Expand Down Expand Up @@ -56,6 +57,8 @@ Split.prototype.start = function () {
this.initControls();

this.tick();

_gaq.push(['_trackEvent', 'Game', 'Play', 'Split', this.plays++]);
};

Split.prototype.gameOver = function () {
Expand Down

0 comments on commit 9885728

Please sign in to comment.