Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1226655

    Hi,

    i want to add Google Tagmanager by code but it doesnt works, here the code:

    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’,’dataLayer’,’GTM-0000000′);
    </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-0000000″
    height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
    <!– End Google Tag Manager (noscript) –><?php

    }
    add_action(‘wp_footer’, ‘google_tag_after_body_script’);

    thanks

    #1226749

    Hey webdesignaustria,

    This part should be changed in both codes: GTM-0000000′
    Can you give us a link to your site? so we can try to inspect if the script isn’t showing.

    Best regards,
    Nikko

    #1226927

    Hi Nikko,

    yes i know thank, now i have add it in backend in Google services und in the header.php
    is this right?

    thanks

    #1227135

    Hi webdesignaustria,

    No, the code should be added in your child theme’s functions.php.
    If you don’t have a child theme yet, then you can download and find instructions here: https://kriesi.at/documentation/enfold/child-theme/

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.