Skip to content

Commit

Permalink
[story/ECP-1061] - Deploy Google Tag Manager ECP Service (#1559)
Browse files Browse the repository at this point in the history
* [story/ECP-1061] - Adding Google Tag Manager to code for application and admin

* Updated dockerfile to remove chown of directories

* [story/ECP-1061] - Adding Google Tag Manager for application and admin

Co-authored-by: and-lucas-kelly <[email protected]>
  • Loading branch information
Katherine Martin and and-lucas-kelly authored Aug 20, 2021
1 parent 869ffad commit e84fae2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,4 @@ RUN touch ${APP_HOME}/log/production.log

RUN chmod 0666 ${APP_HOME}/log/production.log

USER appuser
USER appuser
12 changes: 12 additions & 0 deletions app/assets/javascripts/google_gtm.js
Original file line number Diff line number Diff line change
@@ -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");
13 changes: 13 additions & 0 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' %>
Expand All @@ -31,6 +33,17 @@
<body class="govuk-template__body">
<%= javascript_include_tag 'js_check' %>

<% if ENV["GOOGLE_ANALYTICS_ID"] %>
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-NL8QB4F"
height="0"
width="0"
style="display:none;visibility:hidden">
</iframe>
</noscript>
<% 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? %>

<a href="#main-content" class="govuk-skip-link">Skip to main content</a>
Expand Down
13 changes: 13 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' %>
Expand All @@ -30,6 +32,17 @@
<body class="govuk-template__body">
<%= javascript_include_tag 'js_check' %>

<% if ENV["GOOGLE_ANALYTICS_ID"] %>
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-NL8QB4F"
height="0"
width="0"
style="display:none;visibility:hidden">
</iframe>
</noscript>
<% 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? %>

<a href="#main-content" class="govuk-skip-link">Skip to main content</a>
Expand Down

0 comments on commit e84fae2

Please sign in to comment.