Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/govuk_tech_docs/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GovukTechDocs
VERSION = "2.0.12".freeze
VERSION = "2.1.0".freeze
end
12 changes: 12 additions & 0 deletions lib/source/layouts/_google_tag_manager_js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %>
<script>
(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','<%= config[:tech_docs][:gtm_id] %>');
</script>
<% end %>
4 changes: 4 additions & 0 deletions lib/source/layouts/_google_tag_manager_non_js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= config[:tech_docs][:gtm_id] %>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<% end %>
2 changes: 2 additions & 0 deletions lib/source/layouts/core.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
<%= tag :meta, property: property, content: content %>
<% end %>

<%= partial 'layouts/google_tag_manager_js' %>
<%= yield_content :head %>
</head>

<body class="govuk-template__body">
<%= partial 'layouts/google_tag_manager_non_js' %>
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>

<div class="app-pane">
Expand Down