diff --git a/CHANGELOG.md b/CHANGELOG.md index d75487ec72..81c42f77cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,8 @@ The format is based on [Keep a Changelog] - Multiple level 1 headings - Error skip links - Non-descriptive links +- Google Analytics + - Add Google Tag Manager to admin and application ## [Release 092] - 2021-07-22 diff --git a/Dockerfile b/Dockerfile index 9fa94e2583..945709405f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -201,4 +201,4 @@ RUN touch ${APP_HOME}/log/production.log RUN chmod 0666 ${APP_HOME}/log/production.log -USER appuser \ No newline at end of file +USER appuser diff --git a/app/assets/javascripts/google_gtm.js b/app/assets/javascripts/google_gtm.js new file mode 100644 index 0000000000..579dd3944c --- /dev/null +++ b/app/assets/javascripts/google_gtm.js @@ -0,0 +1,12 @@ +"use strict"; + +(function (w, d, s, l, i) { + w[l] = w[l] || []; + w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" }); + var f = d.getElementsByTagName(s)[0], + j = d.createElement(s), + dl = l != "dataLayer" ? "&l=" + l : ""; + j.async = true; + j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl; + f.parentNode.insertBefore(j, f); +})(window, document, "script", "dataLayer", "GTM-NL8QB4F"); diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index a3b513b6d3..9d9fa4989f 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -23,6 +23,8 @@ <% if ENV["GOOGLE_ANALYTICS_ID"] %> <%= javascript_include_tag "google_analytics/analytics" %> <%= javascript_include_tag "google_analytics", data: { "ga-id" => ENV["GOOGLE_ANALYTICS_ID"] } %> + + <%= javascript_include_tag "google_gtm" %> <% end %> <%= stylesheet_link_tag 'application', media: 'all' %> @@ -31,6 +33,17 @@ <%= javascript_include_tag 'js_check' %> + <% if ENV["GOOGLE_ANALYTICS_ID"] %> + + <% end %> + <%= render("timeout_dialog", timeout_in_minutes: admin_timeout_in_minutes, path_on_timeout: admin_sign_in_path, refresh_session_path: admin_refresh_session_path) if admin_signed_in? %> Skip to main content diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9c977e88df..24c08169cd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,6 +22,8 @@ <% if ENV["GOOGLE_ANALYTICS_ID"] %> <%= javascript_include_tag "google_analytics/analytics" %> <%= javascript_include_tag "google_analytics", data: { "ga-id" => ENV["GOOGLE_ANALYTICS_ID"] } %> + + <%= javascript_include_tag "google_gtm" %> <% end %> <%= stylesheet_link_tag 'application', media: 'all' %> @@ -30,6 +32,17 @@ <%= javascript_include_tag 'js_check' %> + <% if ENV["GOOGLE_ANALYTICS_ID"] %> + + <% end %> + <%= render("timeout_dialog", timeout_in_minutes: claim_timeout_in_minutes, path_on_timeout: timeout_claim_path(current_policy_routing_name), refresh_session_path: refresh_session_path) if claim_in_progress? %> Skip to main content