Skip to content

Commit

Permalink
Update to GA4
Browse files Browse the repository at this point in the history
  • Loading branch information
billmei committed Jun 4, 2022
1 parent 38b1bee commit 4a5f61c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,16 @@ <h2>Enemy Fleet</h2>

<a href="https://github.com/billmei/battleboat"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>

<script async src="https://www.googletagmanager.com/gtag/js?id=G-MDXLY4NGC1"></script>
<script>
// Don't change this variable.
var DEBUG_MODE = localStorage.getItem('DEBUG_MODE') === 'true';
// To turn DEBUG_MODE on, run `setDebug(true);` in the console.
if (!DEBUG_MODE) {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-10730961-10', 'auto');
ga('send', 'pageview');
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MDXLY4NGC1');
}
</script>

Expand Down
6 changes: 3 additions & 3 deletions js/battleboat.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ Stats.prototype.wonGame = function() {
this.gamesPlayed++;
this.gamesWon++;
if (!DEBUG_MODE) {
ga('send', 'event', 'gameOver', 'win', this.uuid);
gtag('event', 'gameOver', {'win': this.uuid});
}
};
Stats.prototype.lostGame = function() {
this.gamesPlayed++;
if (!DEBUG_MODE) {
ga('send', 'event', 'gameOver', 'lose', this.uuid);
gtag('event', 'gameOver', {'lose': this.uuid});
}
};
// Saves the game statistics to localstorage, also uploads where the user placed
Expand Down Expand Up @@ -111,7 +111,7 @@ Stats.prototype.syncStats = function() {
}

if (!DEBUG_MODE) {
ga('send', 'event', 'humanGrid', stringifiedGrid, this.uuid);
gtag('event', 'humanGrid', {stringifiedGrid: this.uuid});
}
};
// Updates the sidebar display with the current statistics
Expand Down

0 comments on commit 4a5f61c

Please sign in to comment.