Added Google Analytics (#749)

This commit is contained in:
farhatahmad 2019-08-19 08:51:57 -04:00 committed by Jesus Federico
parent c31cf17b22
commit 96ace3265e
4 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -16,6 +16,18 @@
<!DOCTYPE html>
<html>
<head>
<% if Rails.configuration.google_analytics %>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="<%= google_analytics_url %>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', "<%= ENV["GOOGLE_ANALYTICS_TRACKING_ID"] %>");
</script>
<% end %>
<title><%= t("bigbluebutton") %></title>
<%= csrf_meta_tags %>

View File

@ -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

View File

@ -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
#