Tagged: GTM
I want to place the Google Tag Manager (GTM) in the header – NOT GA! These conditions:
– No plugin
– Opt-out option in the Enfold> Google Services panel [av_privacy_google_tracking]
Question: Is there a function that makes this possible? Similar to this:
function google_tag_head_script () {
?>
<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 =?
'Https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
}) (Window, document, 'Script', 'data layer', 'GTM-XXXXXXX');
</ Script> <? Php
}
add_action ('wp_head', 'google_tag_head_script');
function google_tag_after_body_script () {
?>
<! - Google Tag Manager (noscript) ->
<noscript> <iframe src = "https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height = "0" width = "0" style = "display: none; visibility: hidden"> </iframe> </noscript>
<! - End Google Tag Manager (noscript) -> <? Php
}
add_action ('after_body', 'google_tag_after_body_script');
… only with opt-out!
… ok, no answer. So you can close this, I will hire a freelancer.