diff --git a/db/patch-add-google-analytics-status-page-tag.sql b/db/patch-add-google-analytics-status-page-tag.sql new file mode 100644 index 000000000..15305ae25 --- /dev/null +++ b/db/patch-add-google-analytics-status-page-tag.sql @@ -0,0 +1,4 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; +ALTER TABLE status_page ADD google_analytics_tag_id TEXT; +COMMIT; diff --git a/server/database.js b/server/database.js index 06b811537..52c701fb5 100644 --- a/server/database.js +++ b/server/database.js @@ -69,6 +69,7 @@ class Database { "patch-ping-packet-size.sql": true, "patch-maintenance-table2.sql": true, "patch-add-gamedig-monitor.sql": true, + "patch-add-google-analytics-status-page-tag.sql": true }; /** diff --git a/server/model/status_page.js b/server/model/status_page.js index 0dabf5ab1..8dbf1a8c2 100644 --- a/server/model/status_page.js +++ b/server/model/status_page.js @@ -225,6 +225,7 @@ class StatusPage extends BeanModel { customCSS: this.custom_css, footerText: this.footer_text, showPoweredBy: !!this.show_powered_by, + googleAnalyticsId: this.google_analytics_tag_id }; } @@ -245,6 +246,7 @@ class StatusPage extends BeanModel { customCSS: this.custom_css, footerText: this.footer_text, showPoweredBy: !!this.show_powered_by, + googleAnalyticsId: this.google_analytics_tag_id }; } diff --git a/server/socket-handlers/status-page-socket-handler.js b/server/socket-handlers/status-page-socket-handler.js index 16d6ee73b..717aba9c4 100644 --- a/server/socket-handlers/status-page-socket-handler.js +++ b/server/socket-handlers/status-page-socket-handler.js @@ -163,6 +163,7 @@ module.exports.statusPageSocketHandler = (socket) => { statusPage.custom_css = config.customCSS; statusPage.show_powered_by = config.showPoweredBy; statusPage.modified_date = R.isoDateTime(); + statusPage.google_analytics_tag_id = config.googleAnalyticsId; await R.store(statusPage); diff --git a/src/pages/StatusPage.vue b/src/pages/StatusPage.vue index 6cecf6682..40a8e7c97 100644 --- a/src/pages/StatusPage.vue +++ b/src/pages/StatusPage.vue @@ -64,6 +64,12 @@ + +
+ + +
+
{{ $t("Custom CSS") }}
@@ -294,6 +300,15 @@ {{ config.customCSS }} + + + + + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', '{{ config.googleAnalyticsId }}'); +