From 487ad74026f4c4278c33c557e2a23f28dbe12c73 Mon Sep 17 00:00:00 2001 From: Gabriele Cirulli Date: Sun, 4 Nov 2018 11:12:06 +0100 Subject: [PATCH] Migrate to gtag.js --- cache.appcache | 2 +- index.html | 19 +++++++++---------- js/application.js | 6 +++++- js/html_actuator.js | 14 ++++++++++---- privacy.html | 21 +++++++++------------ 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/cache.appcache b/cache.appcache index 7194fdc..cee9dad 100644 --- a/cache.appcache +++ b/cache.appcache @@ -3,7 +3,7 @@ CACHE MANIFEST # Adds the ability to play the game offline. # The following comment needs to be updated whenever a change is made. # Run `rake appcache:update` to do so -# Updated: 2018-10-27T21:30:00+02:00 +# Updated: 2018-11-04T11:11:51+01:00 # Main page index.html diff --git a/index.html b/index.html index 1e56cc7..07ce42c 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,15 @@ 2048 + + + @@ -171,15 +180,5 @@ - - diff --git a/js/application.js b/js/application.js index 9e9e195..9b52c57 100644 --- a/js/application.js +++ b/js/application.js @@ -12,7 +12,11 @@ window.requestAnimationFrame(function () { noticeClose.addEventListener("click", function () { notice.parentNode.removeChild(notice); storage.setNoticeClosed(true); - ga("send", "event", "notice", "closed"); + if (typeof gtag !== undefined){ + gtag("event", "closed", { + event_category: "notice", + }); + } }); } }); diff --git a/js/html_actuator.js b/js/html_actuator.js index a37b8fe..b162850 100644 --- a/js/html_actuator.js +++ b/js/html_actuator.js @@ -38,8 +38,10 @@ HTMLActuator.prototype.actuate = function (grid, metadata) { // Continues the game (both restart and keep playing) HTMLActuator.prototype.continueGame = function () { - if (typeof ga !== "undefined") { - ga("send", "event", "game", "restart"); + if (typeof gtag !== "undefined") { + gtag("event", "restart", { + event_category: "game", + }); } this.clearMessage(); @@ -133,8 +135,12 @@ HTMLActuator.prototype.message = function (won) { var type = won ? "game-won" : "game-over"; var message = won ? "You win!" : "Game over!"; - if (typeof ga !== "undefined") { - ga("send", "event", "game", "end", type, this.score); + if (typeof gtag !== "undefined") { + gtag("event", "end", { + event_category: "game", + event_label: type, + value: this.score, + }); } this.messageContainer.classList.add(type); diff --git a/privacy.html b/privacy.html index 4c3f094..325aa32 100644 --- a/privacy.html +++ b/privacy.html @@ -5,6 +5,15 @@ Privacy Policy — 2048 + + + @@ -102,18 +111,6 @@ me@gabrielecirulli.com

- - \ No newline at end of file -- GitLab