diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 36959085..e1e901c2 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -135,4 +135,8 @@ module ApplicationHelper
Rails.application.routes.recognize_path(request.env['PATH_INFO'])[:action] == "edit_user" &&
@user.greenlight_account?
end
+
+ def google_analytics_url
+ "https://www.googletagmanager.com/gtag/js?id=#{ENV['GOOGLE_ANALYTICS_TRACKING_ID']}"
+ end
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 8c730423..f37c4d04 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -16,6 +16,18 @@
+ <% if Rails.configuration.google_analytics %>
+
+
+
+ <% end %>
+
<%= t("bigbluebutton") %>
<%= csrf_meta_tags %>
diff --git a/config/application.rb b/config/application.rb
index 1b492a3a..b9ae60fe 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -116,6 +116,8 @@ module Greenlight
# Enum containing the different possible registration methods
config.registration_methods = { open: "0", invite: "1", approval: "2" }
+ config.google_analytics = ENV["GOOGLE_ANALYTICS_TRACKING_ID"].present?
+
# DEFAULTS
# Default branding image if the user does not specify one
diff --git a/sample.env b/sample.env
index f50bf80e..e11137d9 100644
--- a/sample.env
+++ b/sample.env
@@ -84,6 +84,12 @@ ALLOW_GREENLIGHT_ACCOUNTS=true
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
+# To enable Google Analytics on your site, set this key to the Google Analytics Property Tracking ID
+#
+# https://analytics.google.com/analytics/web/
+#
+GOOGLE_ANALYTICS_TRACKING_ID=
+
# Set this to true if you want GreenLight to send verification emails upon
# the creation of a new account
#