mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
FIX: update Google Tag Manager javascript
This commit is contained in:
parent
76d734ea6e
commit
b7ecdb72d6
@ -5,9 +5,15 @@ module CommonHelper
|
||||
end
|
||||
end
|
||||
|
||||
def render_google_tag_manager_code
|
||||
def render_google_tag_manager_head_code
|
||||
if Rails.env.production? && SiteSetting.gtm_container_id.present?
|
||||
render partial: "common/google_tag_manager"
|
||||
render partial: "common/google_tag_manager_head"
|
||||
end
|
||||
end
|
||||
|
||||
def render_google_tag_manager_body_code
|
||||
if Rails.env.production? && SiteSetting.gtm_container_id.present?
|
||||
render partial: "common/google_tag_manager_body"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
4
app/views/common/_google_tag_manager_body.html.erb
Normal file
4
app/views/common/_google_tag_manager_body.html.erb
Normal file
@ -0,0 +1,4 @@
|
||||
<!-- Google Tag Manager (noscript) -->
|
||||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= SiteSetting.gtm_container_id %>"
|
||||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<!-- End Google Tag Manager (noscript) -->
|
@ -2,10 +2,10 @@
|
||||
dataLayer = [<%= google_tag_manager_json %>];
|
||||
</script>
|
||||
|
||||
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<%= SiteSetting.gtm_container_id %>"
|
||||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
||||
<!-- Google Tag Manager -->
|
||||
<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=
|
||||
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||
})(window,document,'script','dataLayer','<%= SiteSetting.gtm_container_id %>');</script>
|
||||
<!-- End Google Tag Manager -->
|
@ -44,6 +44,7 @@
|
||||
<%= raw theme_lookup("head_tag") %>
|
||||
<%- end %>
|
||||
|
||||
<%= render_google_tag_manager_head_code %>
|
||||
<%= render_google_universal_analytics_code %>
|
||||
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.json">
|
||||
|
||||
@ -60,8 +61,7 @@
|
||||
</head>
|
||||
|
||||
<body class="<%= body_classes %>">
|
||||
<%= render_google_tag_manager_code %>
|
||||
|
||||
<%= render_google_tag_manager_body_code %>
|
||||
<noscript data-path="<%= request.env['PATH_INFO'] %>">
|
||||
<%= render partial: 'header' %>
|
||||
<div id="main-outlet" class="wrap">
|
||||
|
Loading…
Reference in New Issue
Block a user