From 9783ac54613f9e3e258840ccc0355e164d9deefa Mon Sep 17 00:00:00 2001 From: grahampaulcook Date: Sun, 19 Jul 2020 23:38:26 +0100 Subject: [PATCH] TRG-317: Provide support for Google Tag Manager This is a cherry-pick of 63b2a304bb5e3f9f149e4a2dc0b5bcf46f216dfc from grahampaulcook/tech-docs-gem which introduces support for Google Tag Manager. A pull request has been raised to include this change: https://github.com/alphagov/tech-docs-gem/pull/187 however GDS have not yet picked it up, so we're pulling it in here for use at HMRC in the meantime. --- lib/source/layouts/_google_tag_manager_js.erb | 12 ++++++++++++ lib/source/layouts/_google_tag_manager_non_js.erb | 4 ++++ lib/source/layouts/core.erb | 2 ++ 3 files changed, 18 insertions(+) create mode 100644 lib/source/layouts/_google_tag_manager_js.erb create mode 100644 lib/source/layouts/_google_tag_manager_non_js.erb diff --git a/lib/source/layouts/_google_tag_manager_js.erb b/lib/source/layouts/_google_tag_manager_js.erb new file mode 100644 index 00000000..1715bc57 --- /dev/null +++ b/lib/source/layouts/_google_tag_manager_js.erb @@ -0,0 +1,12 @@ +<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %> + +<% end %> diff --git a/lib/source/layouts/_google_tag_manager_non_js.erb b/lib/source/layouts/_google_tag_manager_non_js.erb new file mode 100644 index 00000000..e666b452 --- /dev/null +++ b/lib/source/layouts/_google_tag_manager_non_js.erb @@ -0,0 +1,4 @@ +<% if config[:tech_docs][:gtm_id].is_a?(String) && !config[:tech_docs][:gtm_id].empty? %> + +<% end %> diff --git a/lib/source/layouts/core.erb b/lib/source/layouts/core.erb index 29fbb481..646aea34 100644 --- a/lib/source/layouts/core.erb +++ b/lib/source/layouts/core.erb @@ -19,10 +19,12 @@ <%= tag :meta, property: property, content: content %> <% end %> + <%= partial 'layouts/google_tag_manager_js' %> <%= yield_content :head %> + <%= partial 'layouts/google_tag_manager_non_js' %>