Migrate to gtag.js

This commit is contained in:
Gabriele Cirulli
2018-11-04 11:12:06 +01:00
parent bacc1519aa
commit 487ad74026
5 changed files with 34 additions and 28 deletions
+10 -4
View File
@@ -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);