Commit daee4737 authored by Illya Klymov's avatar Illya Klymov

Merge branch 'fix-google-tag-manager-nonce-value' into 'master'

Fix Google Tag Manager nonce value missing

See merge request gitlab-org/gitlab!76585
parents 60f4f450 d954118d
- return unless google_tag_manager_enabled? - return unless google_tag_manager_enabled?
- if Feature.enabled?(:gtm_nonce, type: :ops) - if Feature.enabled?(:gtm_nonce, type: :ops)
= javascript_tag do = javascript_tag nonce: content_security_policy_nonce do
:plain :plain
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': (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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;var n=d.querySelector('[nonce]'); 'https://www.googletagmanager.com/gtm.js?id='+i+dl;j.setAttribute('nonce',
n&&j.setAttribute('nonce',n.nonce||n.getAttribute('nonce'));f.parentNode.insertBefore(j,f); '#{content_security_policy_nonce}');f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','#{google_tag_manager_id}'); })(window,document,'script','dataLayer','#{google_tag_manager_id}');
- else - else
= javascript_tag do = javascript_tag do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment