FIX: update Google Tag Manager javascript
This commit is contained in:
parent
76d734ea6e
commit
b7ecdb72d6
|
@ -5,9 +5,15 @@ module CommonHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_google_tag_manager_code
|
def render_google_tag_manager_head_code
|
||||||
if Rails.env.production? && SiteSetting.gtm_container_id.present?
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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 %>];
|
dataLayer = [<%= google_tag_manager_json %>];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=<%= SiteSetting.gtm_container_id %>"
|
<!-- Google Tag Manager -->
|
||||||
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
|
||||||
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
<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],
|
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=
|
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>
|
})(window,document,'script','dataLayer','<%= SiteSetting.gtm_container_id %>');</script>
|
||||||
|
<!-- End Google Tag Manager -->
|
|
@ -44,6 +44,7 @@
|
||||||
<%= raw theme_lookup("head_tag") %>
|
<%= raw theme_lookup("head_tag") %>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
|
<%= render_google_tag_manager_head_code %>
|
||||||
<%= render_google_universal_analytics_code %>
|
<%= render_google_universal_analytics_code %>
|
||||||
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.json">
|
<link rel="manifest" href="<%= Discourse.base_uri %>/manifest.json">
|
||||||
|
|
||||||
|
@ -60,8 +61,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="<%= body_classes %>">
|
<body class="<%= body_classes %>">
|
||||||
<%= render_google_tag_manager_code %>
|
<%= render_google_tag_manager_body_code %>
|
||||||
|
|
||||||
<noscript data-path="<%= request.env['PATH_INFO'] %>">
|
<noscript data-path="<%= request.env['PATH_INFO'] %>">
|
||||||
<%= render partial: 'header' %>
|
<%= render partial: 'header' %>
|
||||||
<div id="main-outlet" class="wrap">
|
<div id="main-outlet" class="wrap">
|
||||||
|
|
Loading…
Reference in New Issue