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

    Dear support, @NIKKO @rikard
    I’ve been trying to implement the Google Tag Code from Google Ads for hours.
    But i get every the error:
    Uncaught Error: Undefined constant “‘wp_head’” in wp-content/themes/enfold-child/functions.php:24
    Stack trace:
    #0 wp-settings.php(672): include()
    #1 wp-config.php(104): require_once(‘/var/www/vhosts…’)
    #2 wp-load.php(50): require_once(‘/var/www/vhosts…’)
    #3 wp-admin/admin.php(34): require_once(‘/var/www/vhosts…’)
    #4 wp-admin/theme-editor.php(10): require_once(‘/var/www/vhosts…’)
    #5 {main}
    thrown
    What its wrong???

    Here is my script
    /**
    * Google Tag Manager Head Script
    */
    function add_custom_gtm(){
    ?>
    <!– Google Tag Manager –>
    <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-ABCDEFGH’);</script>
    <!– End Google Tag Manager –>
    <?php
    }

    add_action(‘wp_head’, ‘add_custom_gtm’);
    /**
    * Google Tag Manager Body Script
    */
    function google_tag_manager_body_code() { ?>
    <!– Google Tag Manager (noscript) –>
    <noscript><iframe src=”https://www.googletagmanager.com/ns.html?id=GTM-ABCDEFGH&#8221;
    height=”0″ width=”0″ style=”display:none;visibility:hidden”></iframe></noscript>
    <!– End Google Tag Manager (noscript) –>
    <?php }
    add_action( ‘ava_after_body_opening_tag’, ‘google_tag_manager_body_code’, 1);

    Can anybody help?

    Sooo great!

    #1473589
    #1473604

    Hi,
    Glad Guenni007 could help, thank you Guenni007, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Google tag manager script in function.php error’ is closed to new replies.