Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1187728

    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!

    #1188508

    … ok, no answer. So you can close this, I will hire a freelancer.

    #1189401

    Hi,

    Sorry for the delay. You can insert the GTM script in the Google Services > Google Analytics field along with the tracking code. Or insert the snippet above in the functions.php file. Have you tried either one of those?

    Best regards,
    Ismael

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.