diff --git a/app/views/layouts/_google_tag_manager.html.erb b/app/views/layouts/_google_tag_manager.html.erb new file mode 100644 index 0000000000..9f24e3abbd --- /dev/null +++ b/app/views/layouts/_google_tag_manager.html.erb @@ -0,0 +1,7 @@ +<% if ENV["GOOGLE_TAG_MANAGER_ID"] %> + <%= render "govuk_publishing_components/components/google_tag_manager_script", { + gtm_id: ENV["GOOGLE_TAG_MANAGER_ID"], + gtm_auth: ENV["GOOGLE_TAG_MANAGER_AUTH"], + gtm_preview: ENV["GOOGLE_TAG_MANAGER_PREVIEW"] + } %> +<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9c77c04d6e..f5970a7c18 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,13 +13,7 @@ dataLayer.push({ 'gtm.blacklist': ['html', 'customScripts', 'nonGoogleScripts', 'customPixels'] }); - <% if ENV["GOOGLE_TAG_MANAGER_ID"] %> - <%= render "govuk_publishing_components/components/google_tag_manager_script", { - gtm_id: ENV["GOOGLE_TAG_MANAGER_ID"], - gtm_auth: ENV["GOOGLE_TAG_MANAGER_AUTH"], - gtm_preview: ENV["GOOGLE_TAG_MANAGER_PREVIEW"] - } %> - <% end %> +<% render "layouts/google_tag_manager" %> <% end %>