Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
added google analytics tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
sroske committed Feb 27, 2012
1 parent 3048d23 commit 986c5ac
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/assets/javascripts/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var countdown = {
timer: null,
init: function() {
this.timer = setTimeout(this.tick.bind(this), 1000);
_gaq.push(['_trackPageview', '/countdown']);
},
tick: function () {
var now = new Date();
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var leaderboard = {
$('.leap-again.button').addClass('hidden');

$('#read-more-button').click(this.handleReadMoreClick);

_gaq.push(['_setCustomVar', 1, 'motionCapable', hasMotionData, 2]);
_gaq.push(['_trackPageview', '/leaderboard']);
},
handleReadMoreClick: function () {
var button = $('#read-more-button');
Expand Down
6 changes: 5 additions & 1 deletion app/assets/javascripts/leap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var leap = {
init: function () {
this.initJumpDetector();
this.initHoldButton();

_gaq.push(['_trackPageview', '/leap']);
},
initHoldButton: function () {
$('#hold-button').bind('touchstart mousedown', this.startGame.bind(this))
Expand Down Expand Up @@ -134,7 +136,7 @@ var leap = {
data: { n: now, s: start, d: inches, x: digest },
success: this.scoreUploaded.bind(this),
error: this.scoreUploadFailed.bind(this)
});
});
}

this.completeSession();
Expand All @@ -152,6 +154,8 @@ var leap = {
$('#result-panel').show();
$('#result-inches').html(inches);
$('#result-total-inches').html(total);

_gaq.push(['_trackEvent', 'leaps', 'leapSubmitted', undefined, inches]);
},
scoreUploadFailed: function ( error ) {
console.log(error);
Expand Down
9 changes: 9 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
<%= yield :stylesheets %>
<%= csrf_meta_tags %>
<script type="text/javascript"> ALREADY_VIEWED_INTRO = <%=params[:i] ? 'true' : 'false'%>; </script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-880454-12']);
(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>
</head>
<!--[if IE]><body class="ie"><![endif]-->
<!--[if !IE]><body><![endif]-->
Expand Down

0 comments on commit 986c5ac

Please sign in to comment.